Answer the question
In order to leave comments, you need to log in
How to parse string in XSLT by delimiter?
Good day!
There is an XML document with unloading of goods. Each card has a tag in which the size is indicated in the form of Width/Height/Length how to split it using the separator / through XSLT and write the values in separate new tags.
From:
<cart>
...
...
...
<dimensions>15.2/44/13.5</dimensions>
...
</cart>
<cart>
...
...
...
<width>15.2</width>
<height>44</height>
<length>13.5</length>
...
</cart>
Answer the question
In order to leave comments, you need to log in
XML
<cart>
<dimensions>15.2/44/13.5</dimensions>
</cart>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/cart">
<div>
<xsl:text>Ширина: </xsl:text>
<xsl:value-of select="substring-before(dimensions, '/')"/>
</div>
<div>
<xsl:text>Высота:</xsl:text>
<xsl:value-of select="substring-before(substring-after(dimensions, '/'), '/')"/>
</div>
<div>
<xsl:text>Глубина:</xsl:text>
<xsl:value-of select="substring-after(substring-after(dimensions, '/'), '/')"/>
</div>
</xsl:template>
</xsl:stylesheet>
<div>Ширина: 15.2</div>
<div>Высота:44</div>
<div>Глубина:13.5</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question