xslt-1.0

xslt 1.0 to convert xs:date to a specific dateFormat DD-MON-YYYY

二次信任 提交于 2020-06-23 18:34:32
问题 I am new to xslt. so this might be a basic question. I am trying to convert a date received in xs:date format to DD-MON-YYYY input received is : <tns:receivedDate>2017-06-27</tns:receivedDate> Output expected <tns:receivedDate>27-JUN-2017</tns:receivedDate> Thanks in advance 回答1: If you mean convert YYYY-MM-DD to DD-MMM-YYYY , try: <xsl:template name="format-date"> <xsl:param name="date"/> <!-- day --> <xsl:value-of select="substring($date, 9, 2)"/> <xsl:text>-</xsl:text> <!-- month --> <xsl

XSLT 1.0: Format JSON output using XSLT/ Remove defualt quotes in an JSON Array

五迷三道 提交于 2020-06-17 09:52:06
问题 I have a the following JSON response, that I'm getting after a XSLT transformation. The values in the "name" array needed to be present as "ABC","XYZ" Payload <Data> <Mapping> <LocationID>001</LocationID> <GeoX>1.00</GeoX> <GeoY>2.00</GeoY> </Mapping> <Mapping> <LocationID>002</LocationID> <GeoX>56.00</GeoX> <GeoY>42.00</GeoY> <Mapping> </Data> Current Code where the Destination object is implemented. <xsl:template match="//Data"> <Destination> <Locations> <xsl:text disable-output-escaping=

Differentiate between similar records

青春壹個敷衍的年華 提交于 2020-05-17 08:08:45
问题 I have some input XML that is auto generated(so I am unable to rename the fields accordingly): <?xml version="1.0" encoding="UTF-8"?> <csv-xml> <record> <csv-field-1>1</csv-field-1> <csv-field-2>12345</csv-field-2> <csv-field-3>7654321</csv-field-3> <csv-field-4>1</csv-field-4> <csv-field-5>08/08/19</csv-field-5> <csv-field-6>08/08/19</csv-field-6> </record> <record> <csv-field-1>2</csv-field-1> <csv-field-2>12345</csv-field-2> <csv-field-3>12345678</csv-field-3> <csv-field-4>3</csv-field-4>

Differentiate between similar records

六眼飞鱼酱① 提交于 2020-05-17 08:07:54
问题 I have some input XML that is auto generated(so I am unable to rename the fields accordingly): <?xml version="1.0" encoding="UTF-8"?> <csv-xml> <record> <csv-field-1>1</csv-field-1> <csv-field-2>12345</csv-field-2> <csv-field-3>7654321</csv-field-3> <csv-field-4>1</csv-field-4> <csv-field-5>08/08/19</csv-field-5> <csv-field-6>08/08/19</csv-field-6> </record> <record> <csv-field-1>2</csv-field-1> <csv-field-2>12345</csv-field-2> <csv-field-3>12345678</csv-field-3> <csv-field-4>3</csv-field-4>

XSLT 1.0 How to get distinct values

十年热恋 提交于 2020-03-23 14:32:32
问题 I had an XML somewhat similar to what is shown below. I had to find the unique categories. There are lot of easy ways in XSLT 2.0. But I had to stick to 1.0 :( . After several struggle I found the solution. I thought of sharing. Might help somebody. Please improve my answer. I appreciate. <root> <category> this is Games category </category> <category> this is Books category </category> <category> this is Food category </category> <category> this is Games category </category> <category> this

Generating UUID in XSLT 1.0

别等时光非礼了梦想. 提交于 2020-02-24 16:52:05
问题 In our legacy project we are using libxslt which is based on xslt 1.0 version. Now there is a need to generate UUID using the xslt file so that our output xml file contains the UUID. As per https://stackoverflow.com/a/8127174/3747770 I am out of luck. Also as per this https://gist.github.com/azinneera/778f69ae6b0049b5edcd69da70072405 we can generate UUID, but using xslt 2.0. I am new to xslt, and is there any way to convert the https://gist.github.com/azinneera

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

試著忘記壹切 提交于 2020-02-15 06:45:47
问题 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

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

微笑、不失礼 提交于 2020-02-15 06:40:22
问题 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

xsl: how to split strings?

半城伤御伤魂 提交于 2020-02-09 01:09:06
问题 I want to split an address on semicolons ( ; ) into rows separated by <br /> : e.g. if address = 123 Elm Street , I want to output 123 Elm Street , but if address = 123 Elm Street;PO Box 222 , I want to output 123 Elm Street<br />PO Box 222 and if address = 123 Elm Street;PO Box 222;c/o James Jones , I want to output 123 Elm Street<br />PO Box 222<br />c/o James Jones Is there a way to do this? (probably easy but I'm not that familiar with XSLT) The plain XSL selector is <xsl:value-of select=

Change pattern's priority or revise the code?

社会主义新天地 提交于 2020-02-07 02:35:08
问题 Here is a code which, in fact, gives the correct output. But the question is about optimizing internal processes. They, conditionally, can be divided into 2 parts. MAIN algorithm (set of codes which create relation chains) DELETE pattern (removes unnecessary nodes, which do not meet the conditions) Patterns' execution priority as i can rate on tests is 1-[MAIN] then finally 2-[DELETE]. But the thing is, the opposite order 1-[DELETE] then 2-[MAIN] would be, as i guess, a more effective