Search Results

Search found 933 results on 38 pages for 'xslt 2 0'.

Page 12/38 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • .NET & XSLT: Unwanted namespace in resulting file after using extension objects (2 replies)

    Hello, after using extension objects in the stylesheets there's an additional namespace entry in the resulting file. How can I prevent that? See: ..NET/C#: XslCompiledTransform xslt new XslCompiledTransform(); .... XsltArgumentList xsltArgs new XsltArgumentList(); xsltArgs.AddExtensionObject(&quot;ibd:DanTe&quot;, this); .... xslt.Transform( source, xsltArgs, target ); XSLT: ?xml version &quot;1.0&quot; encoding &quot;UTF...

    Read the article

  • .NET & XSLT: Unwanted namespace in resulting file after using extension objects (2 replies)

    Hello, after using extension objects in the stylesheets there's an additional namespace entry in the resulting file. How can I prevent that? See: ..NET/C#: XslCompiledTransform xslt new XslCompiledTransform(); .... XsltArgumentList xsltArgs new XsltArgumentList(); xsltArgs.AddExtensionObject(&quot;ibd:DanTe&quot;, this); .... xslt.Transform( source, xsltArgs, target ); XSLT: ?xml version &quot;1.0&quot; encoding &quot;UTF...

    Read the article

  • How do i modify the XSL to change the xml format.

    - by user323719
    In the below XSL. <xsl:param name="insert-file" as="document-node()" /> <xsl:template match="*"> <xsl:variable name="input">My text</xsl:variable> <xsl:variable name="Myxml" as="element()*"> <xsl:call-template name="populateTag"> <xsl:with-param name="nodeValue" select="$input"/> </xsl:call-template> </xsl:variable> <xsl:copy-of select="$Myxml"></xsl:copy-of> </xsl:template> <xsl:template name="populateTag"> <xsl:param name="nodeValue"/> <xsl:for-each select="$insert-file/insert-data/data"> <xsl:choose> <xsl:when test="@index = 1"> <a><xsl:value-of select="$nodeValue"></xsl:value-of></a> </xsl:when> </xsl:choose> </xsl:for-each> </xsl:template> I am getting the output as: <?xml version="1.0" encoding="UTF-8"? <aMy text</a <aMy text</a <aMy text</a <aMy text</a I want template "populateTag" to retun me the xml in the below format. How do i modify the template "populateTag" to achive the same. Expected output from template "populateTag": <?xml version="1.0" encoding="UTF-8"? <a<a<a<aMy text</a</a</a</a Please give your ideas.

    Read the article

  • Improving the performance of XSL

    - by Rachel
    In the below XSL for the variable "insert-data", I have an input param with the structure, <insert-data> <data compareIndex="4" nodeName="d1e1"> <a/> </data> <data compareIndex="5" nodeName="d1e1"> <b/> </data> <data compareIndex="7" nodeName="d1e2"> <a/> </data> <data compareIndex="9" nodeName="d1e2"> <b/> </data> </insert-data> where "nodeName" is the id of a node and "compareIndex" is the position of the text content relative to the node having id "$nodeName". I am using the below XSL to select all the text nodes(generate-id) that satisfy the above condition and construct a data xml. The below implementation works perfectly but the time taken for the execution is in min. Is there a better way of implementing or is there any in-efficient operation being used. From my observation the code where the preceding text length is calculated consumes the major time. Please share your thoughts to improve the performance of the XSL. I am using Java SAXON XSL transformer. <xsl:variable name="insert-data" as="element()*"> <xsl:for-each select="$insert-file/insert-data/data"> <xsl:sort select="xsd:integer(@index)"/> <xsl:variable name="compareIndex" select="xsd:integer(@compareIndex)" /> <xsl:variable name="nodeName" select="@nodeName" /> <xsl:variable name="nodeContent" as="node()"> <xsl:copy-of select="node()"/> </xsl:variable> <xsl:for-each select="$main-root/*//text()[ancestor::*[@id = $nodeName]]"> <xsl:variable name="preTextLength" as="xsd:integer" select="sum((preceding::text())[. ancestor::*[@id = $nodeName]]/string-length(.))" /> <xsl:variable name="currentTextLength" as="xsd:integer" select="string-length(.)" /> <xsl:variable name="sum" select="$preTextLength + $currentTextLength" as="xsd:integer"></xsl:variable> <xsl:variable name="split-index" select="$compareIndex - $preTextLength" as="xsd:integer"></xsl:variable> <xsl:if test="($sum ge $compareIndex) and ($compareIndex gt $preTextLength)"> <data split-index="{$split-index}" text-id="{generate-id(.)}"> <xsl:copy-of select="$nodeContent"/> </data> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:variable>

    Read the article

  • Merge functionality of two xsl files into a single file (not a xsl import or include issue)

    - by anuamb
    I have two xsl files; both of them perform different tasks on source xml one after another. Now I need a single xsl file which will actually perform both these tasks in single file (its not an issue of xsl import or xsl include): say my source xml is: <LIST_R7P1_1 <R7P1_1 <LVL2 <ORIG_EXP_PRE_CONV#+# <EXP_AFT_CONVabc <GUARANTEE_AMOUNT#+# <CREDIT_DER/ </LVL2 <LVL21 <AZ#+# <BZbz1 <AZaz2 <BZ#+# <CZ/ </LVL21 </R7P1_1 </LIST_R7P1_1 My first xsl (tr1.xsl) removes all nodes whose value is blank or null: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@*|node()"> <xsl:if test=". != '' or ./@* != ''"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:if> <xsl:template </xsl:stylesheet The output here is <LIST_R7P1_1 <R7P1_1 <LVL2 <ORIG_EXP_PRE_CONV#+# <EXP_AFT_CONVabc <GUARANTEE_AMOUNT#+# </LVL2 <LVL21 <AZ#+# <BZbz1 <AZaz2 <BZ#+# </LVL21 </R7P1_1 </LIST_R7P1_1 And my second xsl (tr2.xsl) does a global replace (of #+# with text blank'') on the output of first xsl: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" <xsl:template name="globalReplace" <xsl:param name="outputString"/ <xsl:param name="target"/ <xsl:param name="replacement"/ <xsl:choose <xsl:when test="contains($outputString,$target)"> <xsl:value-of select= "concat(substring-before($outputString,$target), $replacement)"/> <xsl:call-template name="globalReplace"> <xsl:with-param name="outputString" select="substring-after($outputString,$target)"/> <xsl:with-param name="target" select="$target"/> <xsl:with-param name="replacement" select="$replacement"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$outputString"/> </xsl:otherwise> </xsl:choose </xsl:template <xsl:template match="text()" <xsl:template match="@*|*"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet So my final output is <LIST_R7P1_1 <R7P1_1 <LVL2 <ORIG_EXP_PRE_CONV <EXP_AFT_CONVabc <GUARANTEE_AMOUNT </LVL2 <LVL21 <AZ <BZbz1 <AZaz2 <BZ </LVL21 </R7P1_1 </LIST_R7P1_1 My concern is that instead of these two xsl (tr1.xsl and tr2.xsl) I only need a single xsl (tr.xsl) which gives me final output? Say when I combine these two as <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:template match="@*|node()" <xsl:if test=". != '' or ./@* != ''"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:if> <xsl:template name="globalReplace" <xsl:param name="outputString"/ <xsl:param name="target"/ <xsl:param name="replacement"/ <xsl:choose <xsl:when test="contains($outputString,$target)"> <xsl:value-of select= "concat(substring-before($outputString,$target), $replacement)"/> <xsl:call-template name="globalReplace"> <xsl:with-param name="outputString" select="substring-after($outputString,$target)"/> <xsl:with-param name="target" select="$target"/> <xsl:with-param name="replacement" select="$replacement"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$outputString"/> </xsl:otherwise> </xsl:choose </xsl:template <xsl:template match="text()" <xsl:call-template name="globalReplace" <xsl:with-param name="outputString" select="."/ <xsl:with-param name="target" select="'#+#'"/ <xsl:with-param name="replacement" select="''"/ </xsl:call-template </xsl:template <xsl:template match="@|" <xsl:copy <xsl:apply-templates select="@*|node()"/ </xsl:copy </xsl:template </xsl:stylesheet it outputs: <LIST_R7P1_1 <R7P1_1 <LVL2 <ORIG_EXP_PRE_CONV <EXP_AFT_CONVabc <GUARANTEE_AMOUNT <CREDIT_DER/ </LVL2 <LVL21 <AZ <BZbz1 <AZaz2 <BZ <CZ/ </LVL21 </R7P1_1 </LIST_R7P1_1 Only replacement is performed but not null/blank node removal.

    Read the article

  • How to pass a string containing both single and double quotes as a parameter to XSLT in PHP?

    - by Boaz
    Hi, I have a simple PHP-based XSLT trasform code that looks like that: $xsl = new XSLTProcessor(); $xsl->registerPHPFunctions(); $xsl->setParameter("","searchterms", $searchterms); $xsl->importStylesheet($xslDoc); echo $xsl->transformToXML($doc); The code passes the variable $searchterms, which contains a string, as a parameter to the XSLT style sheet which in turns uses it as a text: <title>search feed for <xsl:value-of select="$searchterms"/></title> This works fine until you try to pass a string with mixes in it, say: $searchterms = '"some"'." text's quotes are mixed." In that point the XSLT processor screams: Cannot create XPath expression (string contains both quote and double-quotes) What is the correct way to safely pass arbitrary strings as input to XSLT? Note that these strings will be used as a text value in the resulting XML and not as an XPATH paramater. Thanks, Boaz

    Read the article

  • Issue with XSL Criteria

    - by Rachel
    I am using the below piece of XSL to select the id of the text nodes whose content has a given index. This index value in input will be relative to a spcified node whose id value is known. The criteria to select the text node is, The text node content should contain a index say 'i' relative to node say 'n' whose id value i know. 'i' and 'id of n' is got as index and nodeName from the input param as seen in the xsl. Node 'd1e5' has the text content whose index ranges from 1 to 33. When i give an index value greater than 33 i want the below criteria to fail but it does not, [sum((preceding::text(), .)[normalize-space()][. >> //*[@id=$nodeName]]/string-length(.)) ge $index] Input xml: <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" id="d1e1"> <head id="d1e3"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title id="d1e5">Every document must have a title</title> </head> <body id="d1e9"> <h1 id="d1e11" align="center">Very Important Heading</h1> <p id="d1e13">Since this is just a sample, I won't put much text here.</p> </body> </html> XSL code used: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xsd" version="2.0"> <xsl:param name="insert-file" as="node()+"> <insert-data><data index="1" nodeName="d1e5"></data><data index="34" nodeName="d1e5"></data></insert-data> </xsl:param> <xsl:param name="nodeName" as="xsd:string" /> <xsl:variable name="main-root" as="document-node()" select="/"/> <xsl:variable name="insert-data" as="element(data)*"> <xsl:for-each select="$insert-file/insert-data/data"> <xsl:sort select="xsd:integer(@index)"/> <xsl:variable name="index" select="xsd:integer(@index)" /> <xsl:variable name="nodeName" select="@nodeName" /> <data text-id="{generate-id($main-root/descendant::text()[sum((preceding::text(), .)[normalize-space()][. >> //*[@id=$nodeName]]/string-length(.)) ge $index][1])}"> </data> </xsl:for-each> </xsl:variable> <xsl:template match="/"> <Output> <xsl:copy-of select="$insert-data" /> </Output> </xsl:template> </xsl:stylesheet> Actual output: <?xml version="1.0" encoding="UTF-8"?> <Output> <data text-id="d1t8"/> <data text-id="d1t14"/> </Output> Expected output: <?xml version="1.0" encoding="UTF-8"?> <Output> <data text-id="d1t8"/> </Output> This solution works fine if index lies between 1 and 33. Any index value greater that 33 causes incorrect text nodes to get selected. I could not understand why the text node 'd1t14' is getting selected. Please share your thoughts.

    Read the article

  • Adding <span> tags to all text nodes between custom self closing tags.

    - by Rachel
    I have a pair of custom self closing tags s1 and s2 defined in namespace x in my xhtml. For each tag pair s1, s2 having the same id, I want to add span tags to all the text nodes between them. Each s1, s2 tag pair have a unique id. The s1 tag has an attribute 'styleName' which needs to be copied as the class name for the span tags populated for the s1,s2 pair. Within a s1, s2 tag pair, other s1, s2 tags can occur. It is the id attribute of the tags s1 and s2 that help us to find the postion from where we need to start populating the span(for text nodes alone) and the end where we need to stop. In case of common text nodes that is part of the multiple s1, s2 pairs then the span tags needs to be opened and closed appropirately as shown in the sample below. I am not specific with the format of the id populated for the span tag. Along as it is unique it is fine. Can we achive this kind of a solution using XSL. I am using Saxon processor. Sample input: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="http://sample.org"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <x:s1 id="1" styleName="name_1"/>is my <x:s2 id="1" />heading</h1> <p> Sample content <x:s1 id="2" styleName="name_2"/> Some text here. </p> <p> Here you <x:s2 id="2" />go. </p> <p> <x:s1 id="3" styleName="name_3"/>This <x:s1 id="4" styleName="name_4"/>is just a simple text <x:s2 id="4" />Some text here.<x:s2 id="3" /> Some content here. </p> <p> Use this <x:s1 id="5" styleName="name_5"/>space. </p> <p> Indroducing <x:s1 id="6" styleName="name_6"/> more information. </p> <p> Can add some <x:s2 id="6" />more content here. </p> <p> Sample content <x:s2 id="5" />Some text here. Some content here. </p> <p> <x:s1 id="7" styleName="name_7"/>This is a complex data. <x:s1 id="8" styleName="name_8"/>Framing a long sentence to <x:s2 id="7" />accomodate all possible <x:s2 id="8" />scenarios. </p> <p> <x:s1 id="9" styleName="name_9"/>More data can be <x:s1 id="10" styleName="name_10"/>added here. </p> <p> Trying to include here. </p> <p> Modifying <x:s2 id="9" />content <x:s2 id="10" />here. </p> </body> </html> Sample output: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="http://sample.org"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <span id="1_1" class="name_1">is my </span>heading</h1> <p> Sample content <span id="2_1" class="name_2"> Some text here.</span> </p> <p> <span id="2_2" class="name_2">Here you </span>go. </p> <p> <span id="3_1" class="name_3">This <span id="4_1" class="name_4">is just a simple text </span>Some text here.</span> Some content here. </p> <p> Use this <span id="5_1" class="name_5">space.</span> </p> <p> <span id="5_2" class="name_5">Indroducing <span id="6_1" class="name_6"> more information.</span></span> </p> <p> <span id="5_3" class="name_5"><span id="6_2" class="name_6">Can add some </span>more content here.</span> </p> <p> <span id="5_4" class="name_5">Sample content </span>Some text here. Some content here. </p> <p> <span id="7_1" class="name_7">This is a complex data.</span> <span id="8_1" class="name_8"><span id="7_2" class="name_7">Framing a long sentence to </span></span><span id="8_2" class="name_8">accomodate all possible </span>scenarios. </p> <p> <span id="9_1" class="name_9">More data can be <span><span id="10_1" class="name_10"><span id="9_2" class="name_9">added here.</span></span> </p> <p> <span id=10_2 class="name_10"><span id="9_3" class="name_9">Trying to include here.</span></span> </p> <p> <span id=10_3 class="name_10"><span id="9_4" class="name_9">Modifying</span></span><span id="10_4" class="name_10">content </span>here. </p> </body> </html> Thanks.

    Read the article

  • Adding <span> tags to all text nodes between custom self closing tags.

    - by Rachel
    I have a pair of custom self closing tags s1 and s2 defined in namespace x in my xhtml. For each tag pair s1, s2 having the same id, I want to add span tags to all the text nodes between them. Each s1, s2 tag pair have a unique id. The s1 tag has an attribute 'styleName' which needs to be copied as the class name for the span tags populated for the s1,s2 pair. Within a s1, s2 tag pair, other s1, s2 tags can occur. It is the id attribute of the tags s1 and s2 that help us to find the postion from where we need to start populating the span(for text nodes alone) and the end where we need to stop. In case of common text nodes that is part of the multiple s1, s2 pairs then the span tags needs to be opened and closed appropirately as shown in the sample below. I am not specific with the format of the id populated for the span tag. As long as it is unique it is fine. Can we achieve this kind of a solution using XSL. I am looking for a XSL based solution for the same. I am using Saxon java processor for XSL. I am trying to achieve this using XSL 2.0. Please share your ideas on this. EDIT: I have edited my sample input and output to make my question more clear. Sample input: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="http://sample.org"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <x:s1 id="1" styleName="name_1"/>is my <x:s2 id="1" />heading</h1> <p> Sample content <x:s1 id="2" styleName="name_2"/> Some text here. </p> <p> Here you <x:s2 id="2" />go. </p> <p> <x:s1 id="3" styleName="name_3"/>This <x:s1 id="4" styleName="name_4"/>is just a simple text <x:s2 id="4" />Some text here.<x:s2 id="3" /> Some content here. </p> <p> Use this <x:s1 id="5" styleName="name_5"/>space. </p> <p> Indroducing <x:s1 id="6" styleName="name_6"/> more information. </p> <p> Can add some <x:s2 id="6" />more content here. </p> <p> Sample content <x:s2 id="5" />Some text here. Some content here. </p> <p> <x:s1 id="7" styleName="name_7"/>This is a complex data. <x:s1 id="8" styleName="name_8"/>Framing a long sentence to <x:s2 id="7" />accomodate all possible <x:s2 id="8" />scenarios. </p> <p> <x:s1 id="9" styleName="name_9"/>More data can be <x:s1 id="10" styleName="name_10"/>added here. </p> <p> Trying to include here. </p> <p> Modifying <x:s2 id="9" />content <x:s2 id="10" />here. </p> </body> </html> Sample output: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:x="http://sample.org"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <span id="1_1" class="name_1">is my </span>heading</h1> <p> Sample content <span id="2_1" class="name_2"> Some text here.</span> </p> <p> <span id="2_2" class="name_2">Here you </span>go. </p> <p> <span id="3_1" class="name_3">This <span id="4_1" class="name_4">is just a simple text </span>Some text here.</span> Some content here. </p> <p> Use this <span id="5_1" class="name_5">space.</span> </p> <p> <span id="5_2" class="name_5">Indroducing <span id="6_1" class="name_6"> more information.</span></span> </p> <p> <span id="5_3" class="name_5"><span id="6_2" class="name_6">Can add some </span>more content here.</span> </p> <p> <span id="5_4" class="name_5">Sample content </span>Some text here. Some content here. </p> <p> <span id="7_1" class="name_7">This is a complex data.</span> <span id="8_1" class="name_8"><span id="7_2" class="name_7">Framing a long sentence to </span></span><span id="8_2" class="name_8">accomodate all possible </span>scenarios. </p> <p> <span id="9_1" class="name_9">More data can be <span><span id="10_1" class="name_10"><span id="9_2" class="name_9">added here.</span></span> </p> <p> <span id=10_2 class="name_10"><span id="9_3" class="name_9">Trying to include here.</span></span> </p> <p> <span id=10_3 class="name_10"><span id="9_4" class="name_9">Modifying</span></span><span id="10_4" class="name_10">content </span>here. </p> </body> </html> Thanks.

    Read the article

  • Actual element tags are not getting captured.

    - by user323719
    I am using the below piece of XSL code to construct a span tag calling a javascript function on mouseover. The input to the javascipt should be a html table. The output from the variable "showContent" gives just the text content but not along with the table tags. How can this be resolved. XSL: <xsl:variable name="aTable" as="element()*"> <table border="0" cellspacing="0" cellpadding="0"> <xsl:for-each select="$capturedTags"> <tr><td><xsl:value-of select="node()" /></td></tr> </xsl:for-each> </table> </xsl:variable> <xsl:variable name="start" select='concat("Tip(&#39;", "")'></xsl:variable> <xsl:variable name="end" select='concat("&#39;)", "")'></xsl:variable> <xsl:variable name="showContent"> <xsl:value-of select='concat($start,$aTable,$end)'/> </xsl:variable> <span xmlns="http://www.w3.org/1999/xhtml" onmouseout="{$hideContent}" onmouseover="{$showContent}" id="{$textNodeId}"><xsl:value-of select="$textNode"></xsl:value-of></span> Actual Output: <span onmouseout="UnTip()" onmouseover="Tip('content1')" id="d1t14"is my </span Expected output: <span onmouseout="UnTip()" onmouseover="Tip('<table><tr><td>content1</td></tr>')" id="d1t14">is my </span> What is the change that needs to done in the above XSL for the table, tr and td tags to get passed?

    Read the article

  • How do i select all the text nodes within a specific element node using XSL?

    - by user323719
    How do i select all the text nodes within a specific element node using XSL? Input xml: <node1 id="1"> <node2 id="2"> <node3 id="3" /> <node4 id="4"> <node5 id="5">Text node1</node5> <node6 id="6">Text node2</node6> </node4> </node2> <node7 id="7">Text node3 <node8 id="8">Text node4</node8> <node9 id="9">Text node5</node9> </node7> <node10 id="10">Text node6</node10> <node11 id="11">Text node3 <node12 id="12">Text node4</node12> <node13 id="13">Text node5</node13> </node11> </node1> Input Param: List of ids of the element nodes whose txt nodes are to be retrieved. <nodes><node>4</node><node>7</node><node>10</node></nodes> Expected Output: Text node1 Text node2 Text node3 Text node4 Text node5 Text node6 How can this be achieved using XSL? Please share your ideas.

    Read the article

  • How to populate the span tags for all text nodes between specific self closing tags.

    - by Rachel
    I want to populate span tags for all text nodes between the self closing tags s1 and s2 having the same id. Eg. For the input: <a> <b>Some <s1 id="1" />text here</b> <c>Some <s2 id="1"/>more text <s1 id="2"/> here<c/> <d>More data</d> <e>Some <s2 id="2" />more data</e> </a> In the above input i want to enclose every text node between <s1 id="1"/> and <s2 id="1" /> with span tags. Also all the text node between <s1 id="2" /> and <s2 id="2" /> Expected Output: <a> <b>Some <span class="spanClass" id="1a">text here</span></b> <c><span class="spanClass" id="1b">Some </span>more text <span class="spanClass" id="2a"> here</span></c> <d><span class="spanClass" id="2b">More data</span></d> <e><span class="spanClass" id="2c">Some </span>more data</e> </a> I am not concened about the pattern of the id tag populated for the span as along it is unique. If the transformation of the input to the output form requires the list of ids of the s1 , s2 tag pairs say 1, 2 etc i can assume that it in place in any form if required. Hope i am clear. How can this be achieved using XSL? EDIT: The input can have any structure and not exactly the same as seen in the sample input. It can have any number of s1, s2 tag pairs but each pair will have a unique id.Adding another sample input and output pattern for more information. Input: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <s1 id="1" />is my <s2 id="1" />heading</h1> <p> Sample content <s1 id="2" />Some text here. Some content here. </p> <p> Here you <s2 id="2" />go. </p> </body> </html> Desired output: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <span id="1">is my </span>heading</h1> <p> Sample content <span id="2">Some text here. Some content here.</span> </p> <p> <span id="2">Here you </span>go. </p> </body> </html>

    Read the article

  • Improving the performance of XSL

    - by Rachel
    I am using the below XSL 2.0 code to find the ids of the text nodes that contains the list of indices that i give as input. the code works perfectly but in terms for performance it is taking a long time for huge files. Even for huge files if the index values are small then the result is quick in few ms. I am using saxon9he Java processor to execute the XSL. <xsl:variable name="insert-data" as="element(data)*"> <xsl:for-each-group select="doc($insert-file)/insert-data/data" group-by="xsd:integer(@index)"> <xsl:sort select="current-grouping-key()"/> <data index="{current-grouping-key()}" text-id="{generate-id( $main-root/descendant::text()[ sum((preceding::text(), .)/string-length(.)) ge current-grouping-key() ][1] )}"> <xsl:copy-of select="current-group()/node()"/> </data> </xsl:for-each-group> </xsl:variable> In the above solution if the index value is too huge say 270962 then the time taken for the XSL to execute is 83427ms. In huge files if the index value is huge say 4605415, 4605431 it takes several minutes to execute. Seems the computation of the variable "insert-data" takes time though it is a global variable and computed only once. Should the XSL be addessed or the processor? How can i improve the performance of the XSL.

    Read the article

  • How do i select the preceding nodes of a text node starting from a specific node and not the root no

    - by Rachel
    How do i select the preceding nodes of a text node starting from a specific node whose id i know instead of getting the text nodes from the root node? When i invoke the below piece from a template match of text node, I get all the preceding text nodes from the root. I want to modify the above piece of code to select only the text nodes that appear after the node having a specific id say 123. i.e something like //*[@id='123'] <xsl:template match="text()[. is $text-to-split]"> <xsl:variable name="split-index" as="xsd:integer" select="$index - sum(preceding::text()/string-length(.))"/> <xsl:value-of select="substring(., 1, $split-index - 1)"/> <xsl:copy-of select="$new"/> <xsl:value-of select="substring(., $split-index)"/> </xsl:template> <xsl:variable name="text-to-split" as="text()?" select="descendant::text()[sum((preceding::text(), .)/string-length(.)) ge $index][1]"/> How do i include the condition in places where i use preceding::text inorder to select preceding text nodes relative to the specific node's id which i know?

    Read the article

  • Why does Saxon evaluate the result-document URI to be the same?

    - by Jan
    My XSL source document looks like this <Topology> <Environment> <Id>test</Id> <Machines> <Machine> <Id>machine1</Id> <modules> <module>m1</module> <module>m2</module> </modules> </Machine> </Machines> </Environment> <Environment> <Id>production</Id> <Machines> <Machine> <Id>machine1</Id> <modules> <module>m1</module> <module>m2</module> </modules> </Machine> <Machine> <Id>machine2</Id> <modules> <module>m3</module> <module>m4</module> </modules> </Machine> </Machines> </Environment> </Topology> I want to create one result-document per machine, so I use the following stylesheet giving modelDir as path for the result-documents as parameter. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" name="myXML" doctype-system="http://java.sun.com/dtd/properties.dtd"/> <xsl:template match="/"> <xsl:for-each-group select="/Topology/Environment/Machines/Machine" group-by="Id"> <xsl:variable name="machine" select="Id"/> <xsl:variable name="filename" select="concat($modelDir,$machine,'.xml')" /> <xsl:message terminate="no">Writing machine description to <xsl:value-of select="$filename"/></xsl:message> <xsl:result-document href="$filename" format="myXML"> <xsl:variable name="currentMachine" select="Id"/> <xsl:for-each select="current-group()/LogicalHosts/LogicalHost"> <xsl:variable name="environment" select="normalize-space(../../../../Id)"/> <xsl:message terminate="no">Module <xsl:value-of select="."/> for <xsl:value-of select="$environment"/></xsl:message> </xsl:for-each> </xsl:result-document> </xsl:for-each-group> </xsl:template> As my messages show me this seems to work fine - if saxon would not evaluate the URI of the result-document to be the same and thus give the following output. Writing machine description to target/build/model/m1.xml Module m1 for test Module m2 for test Module m1 for production Module m2 for production Writing machine description to target/build/model/m2.xml Error at xsl:result-document on line 29 of file:/C:/Projekte/.../machine.xsl: XTDE1490: Cannot write more than one result document to the same URI, or write to a URI that has been read: file:/C:/Projekte/.../$filename file:/C:/Projekte/.../machine.xsl(29,-1) : here Cannot write more than one result document to the same URI, or write to a URI that has been read: file:/C:/Projekte/.../$filename ; SystemID: file:/C:/Projekte/.../machine.xsl; Line#: 29; Column#: -1 net.sf.saxon.trans.DynamicError: Cannot write more than one result document to the same URI, or write to a URI that has been read: file:/C:/Projekte/.../$filename at net.sf.saxon.instruct.ResultDocument.processLeavingTail(ResultDocument.java:300) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:365) at net.sf.saxon.instruct.Instruction.process(Instruction.java:91) Any ideas on how to solve this?

    Read the article

  • How do i modify the text content within a specified set of nodes using XSL?

    - by user323719
    I have a list of node ids. I want to append "-Selected" to all the text nodes within the given set of node ids. Please let me know how we can achieve the same using XSL? Input: <node1 id="a"> <node2 id="b"> <node3 id="c" /> <node4 id="d"> <node5 id="e">Text node1</node5> <node6 id="f">Text node2</node6> </node4> </node2> <node7 id="g">Text node3 <node8 id="h" align="center">Text node4</node8> <node9 id="i">Text node5</node9> </node7> <node10 id="j">Text node6 </node10> <node11 id="h">Text node7 </node11> Input Param: List of node ids <xsl:param name="pNodes"> <nodes> <node>4</node> <node>7</node> <node>11</node> </nodes> Expected output: <node1 id="a"> <node2 id="b"> <node3 id="c" /> <node4 id="d"> <node5 id="e">Text node1 - Selected</node5> <node6 id="f">Text node2 - Selected</node6> </node4> </node2> <node7 id="g">Text node3 <node8 id="h" align="center">Text node4 - Selected</node8> <node9 id="i">Text node5 - Selected</node9> </node7> <node10 id="j">Text node6 </node10> <node11 id="h">Text node7 - Selected </node11>

    Read the article

  • Iterate through every node in a XML

    - by Rachel
    Hi I am trying to iterate through every node in a xml, be it the element node, text node or comment. With the below XSL in the very first statement prints the complete xml. How do i copy the very first node in $nodes and call the template process-nodes again removing teh first node in my next iteration? <?xml version='1.0'?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:call-template name="process-nodes"> <xsl:with-param name="nodes" select="//node()" as="node()*"/> </xsl:call-template> </xsl:template> <xsl:template name="process-nodes"> <xsl:param name="nodes" as="node()*" /> <xsl:copy-of select="$nodes[1]"/> <xsl:if test="$nodes"> <xsl:call-template name="process-nodes"> <xsl:with-param name="nodes" select="remove($nodes, 1)" /> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> Note: I am looking for fixing the issue in this kind of implementation rather than changing the template match to <xsl:template match="@* | node()"> as I need to have some processing which requires this approach. Thanks.

    Read the article

  • How do i select all text nodes using XSL?

    - by user323719
    I want to get the generate-id(.) of all the text nodes after node and before node . I am looking for some generic XSL and not tightly coupled to the sample input pattern mentioned below. For any input pattern i want to get the ids of all the text nodes between node and . Sample input for better understanding: <a> <b> <c> This is first text node </c> </b> <d> <e> This is my second text node </e> <f> This is my <m/>third text node </f> <g> One more text node </g> <h> <i> This is my fourth text node </i> </h> <j> This is my fifth <n/>text node </j> <k> <l> This is my sixth text node </l> </k> </d> </a> Expected output: Generate id of the text nodes with values "third text node ", "One more text node", "This is my fourth text node", "This is my fifth" which lie inbetween nodes <m/> and <n/> Please give your ideas.

    Read the article

  • Merge functionality of two xsl files into a single file (continued.....)

    - by anuamb
    This is in continuation of my question: Merge functionality of two xsl files into a single file (not a xsl import or include issue) I have to merge the solution (xsl) of above question to below xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <Declaration> <Message> <Meduim> <xsl:value-of select="/Declaration/Message/Meduim"/> </Meduim> <MessageIdentifier> <xsl:value-of select="/Declaration/Message/MessageIdentifier"/> </MessageIdentifier> <ControlingAgencyCode> <xsl:value-of select="/Declaration/Message/ControlingAgencyCode"/> </ControlingAgencyCode> <AssociationAssignedCode> <xsl:value-of select="/Declaration/Message/AssociationAssignedCode"/> </AssociationAssignedCode> <CommonAccessReference> <xsl:value-of select="/Declaration/Message/CommonAccessReference"/> </CommonAccessReference> </Message> <BeginingOfMessage> <MessageCode> <xsl:value-of select="/Declaration/BeginingOfMessage/MessageCode"/> </MessageCode> <DeclarationCurrency> <xsl:value-of select="/Declaration/BeginingOfMessage/DeclarationCurrency"/> </DeclarationCurrency> <MessageFunction> <xsl:value-of select="/Declaration/BeginingOfMessage/MessageFunction"/> </MessageFunction> </BeginingOfMessage> <Header> <ProcessingInformation> <xsl:for-each select="/Declaration/Header/ProcessingInformation/ProcessingInstructions"> <ProcessingInstructions> <xsl:value-of select="."/> </ProcessingInstructions> </xsl:for-each> </ProcessingInformation> <xsl:for-each select="/Declaration/Header/Seal"> <Seal> <SealID> <xsl:value-of select="SealID"/> </SealID> <SealLanguage> <xsl:value-of select="SealLanguage"/> </SealLanguage> </Seal> </xsl:for-each> <xsl:choose> <xsl:when test='/Declaration/Header/DeclarantsReference = ""'> <DeclarantsReference> <xsl:text disable-output-escaping="no">A</xsl:text> </DeclarantsReference> </xsl:when> <xsl:otherwise> <DeclarantsReference> <xsl:value-of select="/Declaration/Header/DeclarantsReference"/> </DeclarantsReference> </xsl:otherwise> </xsl:choose> <xsl:for-each select="/Declaration/Header/Items"> <Items> <CustomsStatusOfGoods> <CPC> <xsl:value-of select="CustomsStatusOfGoods/CPC"/> </CPC> <CommodityCode> <xsl:value-of select="CustomsStatusOfGoods/CommodityCode"/> </CommodityCode> <ECSuplementaryMeasureCode1> <xsl:value-of select="CustomsStatusOfGoods/ECSuplementaryMeasureCode1"/> </ECSuplementaryMeasureCode1> <ECSuplementaryMeasureCode2> <xsl:value-of select="CustomsStatusOfGoods/ECSuplementaryMeasureCode2"/> </ECSuplementaryMeasureCode2> <PreferenceCode> <xsl:value-of select="CustomsStatusOfGoods/PreferenceCode"/> </PreferenceCode> </CustomsStatusOfGoods> <xsl:for-each select="ItemAI"> <ItemAI> <AICode> <xsl:value-of select="AICode"/> </AICode> <AIStatement> <xsl:value-of select="AIStatement"/> </AIStatement> <AILanguage> <xsl:value-of select="AILanguage"/> </AILanguage> </ItemAI> </xsl:for-each> <Locations> <CountryOfOriginCode> <xsl:value-of select="Locations/CountryOfOriginCode"/> </CountryOfOriginCode> <xsl:for-each select="Locations/ItemCountryonRouteCode"> <ItemCountryonRouteCode> <xsl:value-of select="."/> </ItemCountryonRouteCode> </xsl:for-each> <ItemDispatchCountry> <xsl:value-of select="Locations/ItemDispatchCountry"/> </ItemDispatchCountry> <ItemDestinationCountry> <xsl:value-of select="Locations/ItemDestinationCountry"/> </ItemDestinationCountry> </Locations> <Measurements> <GrossMass> <xsl:value-of select="Measurements/GrossMass"/> </GrossMass> <NetMass> <xsl:value-of select="Measurements/NetMass"/> </NetMass> <SupplementaryUnits> <xsl:value-of select="Measurements/SupplementaryUnits"/> </SupplementaryUnits> <ThirdQuantity> <xsl:value-of select="Measurements/ThirdQuantity"/> </ThirdQuantity> </Measurements> <xsl:for-each select="Package"> <Package> <PackageNumber> <xsl:value-of select="PackageNumber"/> </PackageNumber> <PackageKind> <xsl:value-of select="PackageKind"/> </PackageKind> <PackageMarks> <xsl:value-of select="PackageMarks"/> </PackageMarks> <PackageLanguage> <xsl:value-of select="PackageLanguage"/> </PackageLanguage> </Package> </xsl:for-each> <PriceValue> <ItemStatisticalValue> <xsl:value-of select="PriceValue/ItemStatisticalValue"/> </ItemStatisticalValue> <ItemPrice> <xsl:value-of select="PriceValue/ItemPrice"/> </ItemPrice> </PriceValue> <ItemReferences> <xsl:for-each select="ItemReferences/ContainerID"> <ContainerID> <xsl:value-of select="."/> </ContainerID> </xsl:for-each> <QuotaNo> <xsl:value-of select="ItemReferences/QuotaNo"/> </QuotaNo> <UNDangerousGoodsCode> <xsl:value-of select="ItemReferences/UNDangerousGoodsCode"/> </UNDangerousGoodsCode> </ItemReferences> <GoodsDescription> <GoodsDescription> <xsl:value-of select="GoodsDescription/GoodsDescription"/> </GoodsDescription> <GoodsDescriptionLanguage> <xsl:value-of select="GoodsDescription/GoodsDescriptionLanguage"/> </GoodsDescriptionLanguage> </GoodsDescription> <Documents> <xsl:for-each select="Documents/PreviousDocument"> <PreviousDocument> <PreviousDocumentKind> <xsl:value-of select="PreviousDocumentKind"/> </PreviousDocumentKind> <PreviousDocumentIdentifier> <xsl:value-of select="PreviousDocumentIdentifier"/> </PreviousDocumentIdentifier> <PreviousDocumentType> <xsl:value-of select="PreviousDocumentType"/> </PreviousDocumentType> <PreviousDocumentLanguage> <xsl:value-of select="PreviousDocumentLanguage"/> </PreviousDocumentLanguage> </PreviousDocument> </xsl:for-each> <xsl:for-each select="Documents/ItemDocument"> <ItemDocument> <DocumentCode> <xsl:value-of select="DocumentCode"/> </DocumentCode> <DocumentPart> <xsl:value-of select="DocumentPart"/> </DocumentPart> <DocumentQuantity> <xsl:value-of select="DocumentQuantity"/> </DocumentQuantity> <DocumentReason> <xsl:value-of select="DocumentReason"/> </DocumentReason> <DocumentReference> <xsl:value-of select="DocumentReference"/> </DocumentReference> <DocumentStatus> <xsl:value-of select="DocumentStatus"/> </DocumentStatus> <DocumentLanguage> <xsl:value-of select="DocumentLanguage"/> </DocumentLanguage> </ItemDocument> </xsl:for-each> </Documents> <Valuation> <ValuationMethodCode> <xsl:value-of select="Valuation/ValuationMethodCode"/> </ValuationMethodCode> <ItemValuationAdjustmentCode> <xsl:value-of select="Valuation/ItemValuationAdjustmentCode"/> </ItemValuationAdjustmentCode> <ItemValuationAdjustmentPercentage> <xsl:value-of select="Valuation/ItemValuationAdjustmentPercentage"/> </ItemValuationAdjustmentPercentage> </Valuation> <ItemTransportChargeMOP> <xsl:value-of select="ItemTransportChargeMOP"/> </ItemTransportChargeMOP> <xsl:for-each select="ItemProcessingInstructions"> <ItemProcessingInstructions> <xsl:value-of select="."/> </ItemProcessingInstructions> </xsl:for-each> </Items> </xsl:for-each> <NumberOfPackages> <xsl:value-of select="/Declaration/Header/NumberOfPackages"/> </NumberOfPackages> </Header> </Declaration> </xsl:template> </xsl:stylesheet> so for source xml <Declaration> <Message> <Meduim>#+#</Meduim> <MessageIdentifier>AA</MessageIdentifier> <CommonAccessReference></CommonAccessReference> </Message> <BeginingOfMessage> <MessageCode>ISD</MessageCode> <DeclarationCurrency></DeclarationCurrency> <MessageFunction>5</MessageFunction> </BeginingOfMessage> </Declaration> the final output is <Declaration> <Message> <Meduim></Meduim> <MessageIdentifier>AA</MessageIdentifier> </Message> <BeginingOfMessage> <MessageCode>ISD</MessageCode> <MessageFunction>5</MessageFunction> </BeginingOfMessage> </Declaration>

    Read the article

  • Basic question in XSL regarding preceding text

    - by Rachel
    I am new to XSL and i have a basic question on the context of using preceding text. My template match is on the text node. I am iterating over an xml file and within my for loop i am trying to take the preceding text of the text node. Unfortunately preceding::text() is not working if i use it within a for loop. I want to use it within the for loop but how can do it? <xsl:template match="text()"> <xsl:variable name="this" as="text()" select="."/> <xsl:for-each select="$input[@id = generate-id(current())]"> <xsl:variable name="preText" as="xsd:integer" select="sum(preceding::text()[. >> //*[@id=@name]]/string-length(.))"/> ... ... </xsl:for-each> </xsl:template>

    Read the article

  • How do i selext text nodes using XSL

    - by user323719
    How do i select all the text nodes within a specific element node using XSL? Input xml: <node1 id="1"> <node2 id="2"> <node3 id="3" /> <node4 id="4"> <node5 id="5">Text node1</node5> <node6 id="6">Text node2</node6> </node4> </node2> <node7 id="7">Text node3 <node8 id="8">Text node4</node8> <node9 id="9">Text node5</node9> </node7> <node10 id="10">Text node6</node10> <node11 id="11">Text node3 <node12 id="12">Text node4</node12> <node13 id="13">Text node5</node13> </node11> </node1> Input Param: List of ids of the element nodes whose txt nodes are to be retrieved. <nodes><node>4</node><node>7</node><node>10</node></nodes> Expected Output: Text node1 Text node2 Text node3 Text node4 Text node5 Text node6 How can this be achieved using XSL? Please share your ideas.

    Read the article

  • How to populate the span tags between specific tags.

    - by Rachel
    I want to populate span tags for all text nodes between the self closing tags s1 and s2 having the same id.If the transformation of the input to the output form requires the list of ids of the s1 , s2 tag pairs say 1, 2 etc i can assume that it is in place in any form if required.The input can have any structure and not exactly the same as seen in the sample input. It can have any number of s1, s2 tag pairs but each pair will have a unique id. Hope i am clear. How can this be achieved using XSL? Input: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <s1 id="1" />is my <s2 id="1" />heading</h1> <p> Sample content <s1 id="2" />Some text here. Some content here. </p> <p> Here you <s2 id="2" />go. </p> </body> </html> Desired output: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>This is my title</title> </head> <body> <h1 align="center">This <span id="1">is my </span>heading</h1> <p> Sample content <span id="2">Some text here. Some content here.</span> </p> <p> <span id="2">Here you </span>go. </p> </body> </html>

    Read the article

  • What is the difference between as="element()+" and as="element()*" in XSL?

    - by Rachel
    What is the difference between using as="element(data)+" and as="element(data)" in xsl:variable. The below XSL solution works if use "+" but not when i use "". Can some one clarify. XSL code: <xsl:variable name="insert-data" as="element(data)+"> <xsl:for-each select="$insert-file/insert-data/data"> <xsl:sort select="xsd:integer(@index)"/> <xsl:variable name="index" select="xsd:integer(@index)" /> <xsl:variable name="nodeName" select="@nodeName" /> <data nodeName="{$nodeName}" index="{@index}" text-id="{$main-root/*//*[@id=$nodeName]/text()[sum((preceding::text(), .)/string-length(.)) ge $index]/generate-id(.)}"> <xsl:copy-of select="node()"/> </data> </xsl:for-each>

    Read the article

  • Issue with undefined namespace

    - by SoBeK
    "xmlns="VL01" Seems to be causing the style-sheet to fail(works fine if removed), do no know how to address it the style-sheet. I feel like this is basic XLST 101 but I am having a hard time wrapping my brain around it. Any assisting would be greatly appreciated. Cheers XML <?xml version="1.0" encoding="utf-8"?> <Report xsi:schemaLocation="VL01 http://site.com/ReportServer?%2FVMS%20Reports%2FVL01&amp;rs%3ACommand=Render&amp;rs%3AFormat=XML&amp;rs%3ASessionID=lk44ff55z5q3ck3b5pfuxo45&amp;rc%3ASchema=True" Name="VL01" textbox41="VL01 - Checklist Report&#xD;&#xA;" textbox1946=" 2) Target Element&#xD;&#xA;     Target Element List&#xD;&#xA;        Windows 7&#xD;&#xA;3) Report Options&#xD;&#xA; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="VL01"> <list2> <Item_Collection> <Item /> </Item_Collection> </list2> <list1> <list1_Details_Group_Collection> <list1_Details_Group Key="V0001070" EffectiveDate="04 Mar 1998 16:03:47:000" LongName2="Name..."/> </list1_Details_Group_Collection> </list1> </Report> XSL <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsl:output method="xml" version="4.0" indent="yes"/> <xsl:variable name="var-checklist_name"> <xsl:value-of select="substring-after(substring-before(translate(Report/@textbox1946, '&#xD;&#xA;', ''),'3)'),'Target&#x00A0;Element&#x00A0;List')"/> </xsl:variable><xsl:template match="/"> <html> <body> <table> <xsl:apply-templates select="Report/list1/list1_Details_Group_Collection"/> </table> </body> </html> </xsl:template> <xsl:template match="Report/list1/list1_Details_Group_Collection"> <xsl:for-each select="list1_Details_Group"> <Import_List> <Checklist_Name> <xsl:value-of select="normalize-space(translate($var-checklist_name, '&#x00A0;', ' '))"/> </Checklist_Name> <Vuln_ID><xsl:value-of select="number(substring-after(@VulKey,'V'))"/></Vuln_ID> <Short_Name><xsl:value-of select="substring(@LongName2,1,255)"/></Short_Name> <Release_Date><xsl:value-of select="substring(@EffectiveDate,1,11)"/></Release_Date> </Import_List> </xsl:for-each> </xsl:template> </xsl:stylesheet>

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >