xslt-1.0

Why replace one attribute by element is valid, and two attributes not?

巧了我就是萌 提交于 2019-12-01 14:29:26
In a identity transform we can delete an attribute by <xsl:template match="@myAttrib"/> this works for any input... And we can "replace" the attribute by an element with <xsl:template match="@myAttrib"><b>my new element</b></xsl:template> ... but it works only when input have only one attribute. By other hand, if I need to replace attribute's value, the xsl:template behaviour is the same, that is, <xsl:template match="@myAttrib">newValue</xsl:template> not replaces the value, but delete attribute and include the "newValue" as a textNode. Why "replace value" is invalid? Why "replace by element"

XSL combining values of siblings if values of an attribute is same

一个人想着一个人 提交于 2019-12-01 14:10:52
This is how my XML looks like <?xml version="1.0"?> <Nodes> <NodeA NodeAattr="123"> <NodeB NodeBattr="456"></NodeB> <NodeC> <NodeD NodeDAttr="ValueD"> <NodeE Name="ValueABC"> "555" </NodeE > <NodeE Name="ValueABC"> "666" </NodeE> </NodeD> </NodeC> </NodeA> </Nodes> If the values of the Name attribute of NodeE are same, concatenate the values of NodeE. And my final output xml has to look like <NodeA NodeAattr="123"> <NodeB NodeBattr="456"></NodeB> <NodeC> <NodeD="ValueD"> <NodeE Name="ValueABC"> "555" , "666" </NodeE > </NodeD> </NodeC> </NodeA> Please provide me with the xsl.. I am using XSLT1

how to copy the data of variable of one foreach to another for each in xslt

寵の児 提交于 2019-12-01 14:04:44
XML <swift> <message> <block2 type="input"> <messageType>102</messageType> <receiverAddress>BKTRUS33XBRD</receiverAddress> <messagePriority>N</messagePriority> </block2> <block3> <tag> <name>32</name> <value>praveen</value> </tag> <tag> <name>42</name> <value>pubby</value> </tag> </block3> <block4> <tag> <name>77</name> <value>pravz</value> </tag> <tag> <name>77</name> <value>pubbypravz</value> </tag> <tag> <name>99</name> <value>USA</value> </tag> <tag> <name>99</name> <value>UK</value> </tag> <tag> <name>76</name> <value>shanmu</value> </tag> </block4> </message> </swift> XSL <xsl:stylesheet

sequences in XSLT

风流意气都作罢 提交于 2019-12-01 13:32:16
问题 my xml input is- <?xml version="1.0" encoding="UTF-8"?> <foo> <bar>bar</bar> <bar>bar</bar> <foobar>foobar</foobar> <foobar>foobar</foobar> <foobar>foobar</foobar> <bar>bar</bar> <bar>bar</bar> </foo> Output using xslt should be <?xml version="1.0" encoding="UTF-8"?> <foo> <s> <s> <bar>bar</bar> <bar>bar</bar> </s> <s> <foobar>foobar></foobar> <foobar>foobar></foobar> <foobar>foobar></foobar> </s> <s> <bar>bar</bar> <bar>bar</bar> </s> </s> </foo> the output should to have sequence-of

Calculating day of the week XSL

元气小坏坏 提交于 2019-12-01 13:19:56
问题 Trying to calculate day of the week number from date. Found some examples in the internet, but instead of day of the week number i see this : NaN. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*"/> <xsl:output indent="yes"/> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="date"> <xsl:copy> <xsl:call-template name="date-format">

Avoid URL-encoding in XSLT with output method html

╄→尐↘猪︶ㄣ 提交于 2019-12-01 12:24:56
I have a transformation that outputs HTML. In order to avoid self-closing tags that could break in older browsers (e.g. <img /> instead of <img></img> ) output-method has to be html . Then though URL-encoding is applied so that it breaks my application. See for example: Input <html> <head> </head> <body> {{example}} <a href="{{example}}" >abc</a> <img src="http://placehold.it/20x20"></img> </body> </html> Transformation <?xml version="1.0" encoding="utf-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /><!-- either -->

How to use attribute values from another XML file as an element value selection in the current XML

你离开我真会死。 提交于 2019-12-01 12:13:37
I have two XML files. One is the main XML file and the other one is used as a lookup table. Here is the main XML: <Report> <row> <field1>test1</field1> <field2>test2</field2> <field3>test3</field3> </row> <row> <field1>test4</field1> <field2>test5</field2> <field3>test6</field3> </row> </Report> The lookup xml file looks like this: <lookup> <fieldmapping name="field1">fieldA</fieldmapping> <fieldmapping name="field2">fieldB</fieldmapping> <fieldmapping name="field3">fieldC</fieldmapping> </lookup> Here is the output xml I want: <Items> <Item> <FieldName name="fieldA">test1</FieldName>

how to copy the data of variable of one foreach to another for each in xslt

泪湿孤枕 提交于 2019-12-01 12:08:38
问题 XML <swift> <message> <block2 type="input"> <messageType>102</messageType> <receiverAddress>BKTRUS33XBRD</receiverAddress> <messagePriority>N</messagePriority> </block2> <block3> <tag> <name>32</name> <value>praveen</value> </tag> <tag> <name>42</name> <value>pubby</value> </tag> </block3> <block4> <tag> <name>77</name> <value>pravz</value> </tag> <tag> <name>77</name> <value>pubbypravz</value> </tag> <tag> <name>99</name> <value>USA</value> </tag> <tag> <name>99</name> <value>UK</value> <

XSL key to get elements that meet specific criteria

十年热恋 提交于 2019-12-01 11:45:03
问题 I am working with table entry elements and want to get all preceding entry elements in the same table that pass the following test: parent::row/preceding-sibling::row/entry [@morerows >= count(parent::row/following-sibling::row [not(preceding-sibling::row/entry [generate-id() = $id])])] [count(preceding-sibling::entry [not(@morerows)]) + 1 = count(current()/preceding-sibling::entry) + 1] The XPath gives me the desired result, but it is painfully slow..... I would like to use a key but am

How to match and wrap identical and adjacent node together in XSLT 1.0?

一世执手 提交于 2019-12-01 11:33:24
I have an XML file that look like this and I'm trying to wrap "Para_bb" node that are adjacent to each other with a div. <Para_a></Para_a> <Para_a></Para_a> <Para_bb></Para_bb> <Para_bb></Para_bb> <Para_bb></Para_bb> <Para_bb></Para_bb> <Para_a></Para_a> <Para_bb></Para_bb> <Para_bb></Para_bb> <Para_a></Para_a> <Para_a></Para_a> <Para_bb></Para_bb> How can I make it look like this? <p></p> <p></p> <div class="blackBox"> <Para_bb></Para_bb> <Para_bb></Para_bb> <Para_bb></Para_bb> <Para_bb></Para_bb> </div> <p></p> <div class="blackBox"> <Para_bb></Para_bb> <Para_bb></Para_bb> </div> <p></p> <p>