How to create an array from a String
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 1
- Joined: Tue Aug 07, 2018 12:28 am
How to create an array from a String
Hi there.
Please, I need help on this, I have this XML tag :
<productsSDWAN_quote>
SD-WAN (30 MB / EDGE 510)$,$SD-WAN GATEWAY 30 MB$,$SD-WAN GATEWAY 100 MB$,$SD-WAN (30 MB / EDGE 510)$,$SD-WAN GATEWAY 30 MB$,$SD-WAN GATEWAY 100 MB$,$
</productsSDWAN_quote>
I used split to split it.
<xsl:variable xmlns:str="http://exslt.org/strings" name="products" select="str:split($main_doc/productsSDWAN_quote, '$,$')"/>
I need create new array with only the products that contains the word "GATEWAY" at its names.
How can I do that using for-each loop through products and catch only the "GATEWAY" ones and create a new list with them?
thanks.
Please, I need help on this, I have this XML tag :
<productsSDWAN_quote>
SD-WAN (30 MB / EDGE 510)$,$SD-WAN GATEWAY 30 MB$,$SD-WAN GATEWAY 100 MB$,$SD-WAN (30 MB / EDGE 510)$,$SD-WAN GATEWAY 30 MB$,$SD-WAN GATEWAY 100 MB$,$
</productsSDWAN_quote>
I used split to split it.
<xsl:variable xmlns:str="http://exslt.org/strings" name="products" select="str:split($main_doc/productsSDWAN_quote, '$,$')"/>
I need create new array with only the products that contains the word "GATEWAY" at its names.
How can I do that using for-each loop through products and catch only the "GATEWAY" ones and create a new list with them?
thanks.
-
- Posts: 9418
- Joined: Fri Jul 09, 2004 5:18 pm
Re: How to create an array from a String
Hi,
Probably instead of the old xslt split utilities you could use the XSLT 2.0 tokenize function. Then wrap each interesting text in an <item> element and have the list of items returned in the variable for further use:
Regards,
Radu
Probably instead of the old xslt split utilities you could use the XSLT 2.0 tokenize function. Then wrap each interesting text in an <item> element and have the list of items returned in the variable for further use:
Code: Select all
<xsl:template match="productsSDWAN_quote">
<xsl:variable name="myInterestingVals">
<xsl:for-each select="tokenize(text(), '\$,\$')">
<xsl:if test="contains(., 'GATEWAY')">
<item>
<xsl:copy-of select="."/>
</item>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="$myInterestingVals/*/text()">
<xsl:message>VAL <xsl:value-of select="."/></xsl:message>
</xsl:for-each>
</xsl:template>
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service