Convert a string into Array
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 25
- Joined: Sun Apr 22, 2018 10:17 pm
Convert a string into Array
Hi everybody, I have an small problem with my code and I think it is not very complicated but I don´t find any solution for it in Internet, my questios is that I have a single string data in a variable defined as xs:string <variable name="data" as="xs:string" select="string('Spain')" /> and I need to call to a function which expect to receive an xs:string* as parameter (an Array) but how can I convert my simple string in one Array without using Tokenize which is not compatible wit the .NET API.
[<variable name="data" as="xs:string" select="string('Spain')" /> --> this is my data
<xsl:function name="receptor"> --> and I want co call this function
<xsl:param name="Countries" as="xs:string*" />
<xsl:sequence ....
</xsl:function[/b]>
Best Regards
[<variable name="data" as="xs:string" select="string('Spain')" /> --> this is my data
<xsl:function name="receptor"> --> and I want co call this function
<xsl:param name="Countries" as="xs:string*" />
<xsl:sequence ....
</xsl:function[/b]>
Best Regards
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Convert a string into Array
Hi,
Maybe you can build your own "tokenize" template:
https://www.oxygenxml.com/archives/xsl- ... 00939.html
then maybe save in a variable the result of the tokenization and apply an XPath on the variable to return only the texts content of the <token> elements.
Regards,
Radu
Maybe you can build your own "tokenize" template:
https://www.oxygenxml.com/archives/xsl- ... 00939.html
then maybe save in a variable the result of the tokenization and apply an XPath on the variable to return only the texts content of the <token> elements.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Convert a string into Array
Hi,
I would not call xs:string* an array, it's actually a sequence of strings, xs:string (0 to many). If your xs:string has a single value, normally you shouldn't have to convert a single xs:string to a sequence yourself. AFAIK Saxon converts it automatically.
But anyway, you can just pass as argument "($data)". This is a sequence of just one xs:string with the value of $data.
Or you can use a variable of type xs:string*, like this:
You can ignore this, if your xs:string has multiple values separated by space that need to be tokenized (separated) into multiple strings.
Regards,
Adrian
I would not call xs:string* an array, it's actually a sequence of strings, xs:string (0 to many). If your xs:string has a single value, normally you shouldn't have to convert a single xs:string to a sequence yourself. AFAIK Saxon converts it automatically.
But anyway, you can just pass as argument "($data)". This is a sequence of just one xs:string with the value of $data.
Or you can use a variable of type xs:string*, like this:
Code: Select all
<xsl:variable name="seq" as="xs:string*" select="($data)"/>
Regards,
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: 25
- Joined: Sun Apr 22, 2018 10:17 pm
Re: Convert a string into Array
that's ok, I've checked sending a simple string and it worked, the problem was that i had an error in the following line and I thought that it was in this line, but sending a simple string to parameter marked as string* doesn't yield any error.
Best Regards
Best Regards
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