xslt-1.0

XSLT 1.0 for-each 'starts-with' (with variable length)

心不动则不痛 提交于 2021-01-29 09:35:09
问题 thinking aloud, re approach(es 🤔) Input collection (xml) records being transformed eg for-each Order. With an xml 'exclude' (reference-collection) param, to filter out records, eg only transform (for-each Order) where ( start of) current order/reference is not equal to any Reference in the References collection. For simplicity, Order input example <Orders> <Order number="1"> <!-- Include --> <Reference>AB123</Reference> </Order> <Order number="2"> <!-- Exclude --> <Reference>C3PO</Reference>

Using XSL:sort within xsl:if

此生再无相见时 提交于 2021-01-29 08:32:50
问题 I'm just figuring out how XSL works... mostly. I have 3 nodes (STUX, KbnApp, KbnStorge) that I want to transform in the same way except for how their list of "Servers" children are sorted. I wanted to do this with a single template that uses an xsl:if to choose an alternate sorting method for the "STUX". But I couldn't get it to work. The STUX Servers should end up in descending order, the others should stay in whatever order they are currently in. Here is my XML <?xml version="1.0" encoding=

Right padding a String with Zeros in XSLT

余生长醉 提交于 2021-01-29 06:50:48
问题 I need to right pad this with leading zeros to a length of 3 in the output (which is fixed length text) Examples: A becomes A00 AB becomes AB0 ABC becomes ABC Please help. 回答1: You could do simply: substring(concat($your-string, '000'), 1, 3) Note that this means that "ABCD" becomes "ABC" . 来源: https://stackoverflow.com/questions/65317883/right-padding-a-string-with-zeros-in-xslt

XML to CSV using XSLT with missing elements

左心房为你撑大大i 提交于 2021-01-29 01:39:06
问题 I need to convert XML into CSV using an XSLT (compatible with .NET framework). For the moment I came up with the following solution: XML: <items> <item> <col1>AAA1</col1> <col2>BBB1</col2> <col3>CCC1</col3> <col4>DDD1</col4> <col5>EEE1</col5> </item> <item> <col1>AAA2</col1> <col2>BBB2</col2> <col5>EEE2</col5> </item> <item> <col1>AAA3</col1> <col2>BBB3</col2> <col3>CCC3</col3> <col4>DDD3</col4> <col5>EEE3</col5> </item> </items> XSLT: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns

XML to CSV using XSLT with missing elements

时光毁灭记忆、已成空白 提交于 2021-01-29 01:35:52
问题 I need to convert XML into CSV using an XSLT (compatible with .NET framework). For the moment I came up with the following solution: XML: <items> <item> <col1>AAA1</col1> <col2>BBB1</col2> <col3>CCC1</col3> <col4>DDD1</col4> <col5>EEE1</col5> </item> <item> <col1>AAA2</col1> <col2>BBB2</col2> <col5>EEE2</col5> </item> <item> <col1>AAA3</col1> <col2>BBB3</col2> <col3>CCC3</col3> <col4>DDD3</col4> <col5>EEE3</col5> </item> </items> XSLT: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns

XML to CSV using XSLT with missing elements

随声附和 提交于 2021-01-29 01:35:27
问题 I need to convert XML into CSV using an XSLT (compatible with .NET framework). For the moment I came up with the following solution: XML: <items> <item> <col1>AAA1</col1> <col2>BBB1</col2> <col3>CCC1</col3> <col4>DDD1</col4> <col5>EEE1</col5> </item> <item> <col1>AAA2</col1> <col2>BBB2</col2> <col5>EEE2</col5> </item> <item> <col1>AAA3</col1> <col2>BBB3</col2> <col3>CCC3</col3> <col4>DDD3</col4> <col5>EEE3</col5> </item> </items> XSLT: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns

How to aggregate nodes in XSLT 1.0?

随声附和 提交于 2021-01-28 21:29:58
问题 I often need to aggregate a sequence of nodes using XSLT 1.0 but I always struggle to find a clean solution. This is a typical example; Input <x>Foo/Red</x> <x>Foo/Green</x> <x>Foo/Blue</x> <x>Bar/Hello</x> <x>Bar/World</x> Desired output <y s="Foo">Red, Green, Blue</y> <y s="Bar">Hello, World</y> I always end up in a mess with this type of problem. Is there an elegant XSLT 1.0 solution to the above? I'm using PHP 's libxslt so I do have the exslt:node-set() function available to use if

Get enum value from string using xslt and xsd

北城余情 提交于 2021-01-28 18:03:36
问题 I am trying to get the enum value of the corresponding string. I am translating one XML into another. For example, the source element is <VehicleBodyType>Van</VehicleBodyType> I need to transform it to <VehicleTypeCode>5</VehicleTypeCode> This is in an XSD: <xs:simpleType name="VehicleBodyType"> <xs:restriction base="xs:string"> <xs:enumeration value="NotProvided" /> <xs:enumeration value="NotApplicable" /> <xs:enumeration value="PassengerCar" /> <xs:enumeration value=

XSLT-1.0: How to insert an element at a specific position with respect to the parent element

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-28 07:22:20
问题 I am trying to find out the position of a child element with respect to its parent. I have the following input XML: <Begin> <tag1>g</tag1> <tag2>b</tag2> <tag3>c</tag3> <tag5>e</tag5> </Begin> I need to know the position of <tag3> with respect to <Begin> , i.e. 3 Can this be done in XSLT? My current XSLT looks like this: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" indent="yes" omit-xml-declaration="yes"/> <xsl:strip

xslt-1.0 iterate over fixed list of values

假如想象 提交于 2021-01-27 14:22:17
问题 I need to generate an XML structure for a fixed number of languages from an input that may or may not contain information for each language. If the information is missing, I need to generate empty elements. The problem is, that I need to iterate over the languages at many places in the output structure. The easiest way would be to use something resembling <xsl:variable name="languages" select="en,de,fr"> <xsl:for-each select="$languages"> ... </xsl:for-each> with the loop appearing wherever I