Wrap node inside xslt element based on condition

I have to wrap certain nodes inside another element conditionally. In the below example I need to wrap CityName inside MyCity if city is Venezia. I have achieved it now, but i think there is better way of writing this without repeating the node. One way is to create a template and call that for… Read More Wrap node inside xslt element based on condition

Converting XML to CSV formate using XSLT

In my case, I’m trying to convert the XML to CSV format using XSLT. But I’m getting the header, which is also iterating and printing again, and I also couldn’t add a new line to the values column. XML input: <EmployeeDetails> <Employee> <FirstName>harry</FirstName> <SecondName>potter</SecondName> <Email>harrypotter@gmail.com</Email> </Employee> <Employee> <FirstName>tony</FirstName> <SecondName>stark</SecondName> <Email>tonystark@gmail.com</Email> </Employee> </EmployeeDetails> My XLST code… Read More Converting XML to CSV formate using XSLT

XSLT – Different context of the FOR extract the value

I need some hits about different context with check of text to extract the correct value. I already did for inside for but no works proper. The XML below: <?xml version="1.0" encoding="UTF-8"?> <ORDERS05> <IDOC BEGIN="1"> <E1EDP01 SEGMENT="1"> <E1EDP05 SEGMENT="1"> <KOTXT>Total item price</KOTXT> <KRATE>20.55</KRATE> </E1EDP05> </E1EDP01> <E1EDP01 SEGMENT="1"> <E1EDP05 SEGMENT="1"> <KOTXT>Total item price</KOTXT> <KRATE>8.03</KRATE> </E1EDP05> </E1EDP01>… Read More XSLT – Different context of the FOR extract the value

XSLT transformation of multiple "flat" XML files into tree-like XML. Continuation – 2 xml files of objects and 1 with hierarchy

This is a continuation of the previous question. XSLT transformation of multiple "flat" XML files into tree-like XML I tried to build xml from more object files and got a problem. what we have: file 1.xml is $doc1 -main objects <?xml version="1.0" encoding="utf-8"?> <ADDRESSOBJECTS> <OBJECT OBJECTID="105037985" NAME="OLDER OTHER PARENT" LEVEL="2" ISACTIVE="0" /> <OBJECT OBJECTID="105037985" NAME="OTHER… Read More XSLT transformation of multiple "flat" XML files into tree-like XML. Continuation – 2 xml files of objects and 1 with hierarchy

how to add attribute to a parent when the text in the child match with XSLT 1.0

Im trying to add an attribute into a parent, when the text in a child node match, I have this input : <CS> <CN name="PICTURE 1"> <TN name="L_1"> <color>red</color> <ptCN>IN4</ptCN> <ID>10</ID> </TN> </CN> <CN name="PICTURE 2"> <TN name="L_2"> <color>blue</color> <ptCN>IN3</ptCN> <ID>20</ID> </TN> </CN> <CS> And when the attribute color = red, I need to add… Read More how to add attribute to a parent when the text in the child match with XSLT 1.0

xslt nested for each

I have the following xml <?xml version="1.0" encoding="UTF-8"?> <root> <employee> <name>a</name> <company>1</company> </employee> <employee> <name>b</name> <company>2</company> </employee> <employee> <name>c</name> <company>1</company> </employee> <employee> <name>d</name> <campany>2</campany> </employee> <employee> <name>e</name> <company>2</company> </employee> <employee> <name>f</name> <company>1</company> </employee> </root> I would like to have sth like <root> <company> <id>1</id> <employee>a</employee> <employee>c</employee> <employee>f</employee> </company> <company> <id>2</id> <employee>b</employee> <employee>d</employee> <employee>e</employee> </company> <root>… Read More xslt nested for each

How to find all not matching elements in XPath expression of XSL template?

This is my XML: <f> <a>10</a> <a>2</a> <a>4</a> <a>13</a> <b>55</b> <b>4</b> </f> I’m trying to match elements <b/> which are not equal to <a/>: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot; version="2.0"> <xsl:template match="b[. != //a]"> <xsl:text>found!</xsl:text> </xsl:template> </xsl:stylesheet> However, it doesn’t work. I believe, my expression . != //a is wrong, since //a matches only the first occurrence of… Read More How to find all not matching elements in XPath expression of XSL template?

XSL rename tag name if condition is met

I have below XML that I need to transform: XML <CONTENT> <DESCRIPTION TYPE="NODE"></DESCRIPTION> <DETAIL TYPE="NODE"></DETAIL> <DATA TYPE="NODE"> <ITEM DESC="ENTITY" VALUE="Y"></ITEM> <ITEM DESC="REQUEST" VALUE="Y"></ITEM> </DATA> </CONTENT> The criteria is for every element having TYPE="NODE" rename the tag name by NODE and have as DESC the previous tag name, this also applies for the root element CONTENT… Read More XSL rename tag name if condition is met

XSLT 1.0 – for-each with a choose variable not giving the right results

Input: <?xml version="1.0" encoding="UTF-8"?> <Project ID="123"> <ProductPool> <Product Type="A" ID="123" DueDate="123" Name="ABC"/> <Product Type="B" ID="123" DueDate="123" Name="ABC"/> <Product Type="A" ID="123" DueDate="123" Name="ABC"/> <Product Type="B" ID="123" DueDate="123" Name="ABC"/> <Product Type="A" ID="123" DueDate="123" Name="ABC"/> </ProductPool> </Project> XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot; version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:element name="Product"> <xsl:attribute name="ID"> <xsl:value-of select="//Project/@ID"/> </xsl:attribute> <xsl:variable name="elem-name">… Read More XSLT 1.0 – for-each with a choose variable not giving the right results