SPLIT DATA IN VARIABLE
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 147
- Joined: Sat Oct 19, 2013 8:21 am
SPLIT DATA IN VARIABLE
Hi,
I have data xml
I would like to make a SPLIT on the # character and retrieve each value in variable named
For the following result :
Can you help me ?
Thank you
I have data xml
Code: Select all
<x>1#2#3#4</x>
For the following result :
Code: Select all
var1="1"
var2="2"
var3="3"
var4="4"
Thank you
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: SPLIT DATA IN VARIABLE
Hi,
You can use the tokenize XSLT 2.0 function:
http://www.w3schools.com/xpath/xpath_functions.asp
e.g.
tokenize('1#2#3#4', '#')
will give you the 4 tokens(1, 2, 3, 4).
Regards,
Adrian
You can use the tokenize XSLT 2.0 function:
http://www.w3schools.com/xpath/xpath_functions.asp
e.g.
tokenize('1#2#3#4', '#')
will give you the 4 tokens(1, 2, 3, 4).
Code: Select all
<xsl:template match="x">
<xsl:for-each select="tokenize(text(), '#')">
<xsl:variable name="token" select="."/>
</xsl:for-each>
</xsl:template>
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 147
- Joined: Sat Oct 19, 2013 8:21 am
Re: SPLIT DATA IN VARIABLE
i use xslt V1.0
I use a solution not terrible
I use a solution not terrible
Code: Select all
<xsl:variable name="var" select="xx"/>
<xsl:variable name="var1" select="substring-before($var, '#')"/>
<xsl:variable name="tmp" select="substring-after($var, '#')"/>
<xsl:variable name="var2" select="substring-before($tmp, '#')"/>
<xsl:variable name="tmp1" select="substring-after($tmp, '#')"/>
...
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