Converting Pipe-Delimited txt to XML
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 2
- Joined: Wed Mar 29, 2006 10:11 pm
Converting Pipe-Delimited txt to XML
Post by diblassio4 »
Hi George, (and everyone else!)
I checked out http://www.oxygenxml.com/forum/ftopic977.html and
I was trying to use the nice example you posted, but using <xsl:analyze-string select="$value" regex="\|"> for pipe-delimited instead.
The problem comes when there is an empty field like such:
field|secondfield|||fifthField (fields 3 and 4 are empty)
field||thirdfield||fifthField (fields 2 and 4 are empty)
then the positions get janked out of consistency in the results...
Any ideas?
Thanks in advance!
I checked out http://www.oxygenxml.com/forum/ftopic977.html and
I was trying to use the nice example you posted, but using <xsl:analyze-string select="$value" regex="\|"> for pipe-delimited instead.
The problem comes when there is an empty field like such:
field|secondfield|||fifthField (fields 3 and 4 are empty)
field||thirdfield||fifthField (fields 2 and 4 are empty)
then the positions get janked out of consistency in the results...
Any ideas?
Thanks in advance!
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Hi,
Sorry for the delay.
If you check the annotation of the "xsl:analyse" tag available in the Model View it says something like: so this means you will not be notified in the "xsl:non-matching-substring" of empty strings.
I found an interesting XSLT 2.0 method called "tokenize" that seems to do exactly the same thing http://www.w3.org/TR/xpath-functions/#func-tokenize but also return the 0-length matches between the separators.
Sample usage:
The code above will also output empty "entry" tags when there is no content between separators.
Hope this helps,
Regards, Radu.
Sorry for the delay.
If you check the annotation of the "xsl:analyse" tag available in the Model View it says something like:
Code: Select all
...Each substring will contain at least one character.
I found an interesting XSLT 2.0 method called "tokenize" that seems to do exactly the same thing http://www.w3.org/TR/xpath-functions/#func-tokenize but also return the 0-length matches between the separators.
Sample usage:
Code: Select all
<xsl:variable name="var"
select="tokenize('field|secondfield|||fifthField', '\|')"/>
<xsl:for-each select="$var">
<entry>
<xsl:value-of select="."/>
</entry>
</xsl:for-each>
Hope this helps,
Regards, Radu.
-
- Posts: 4
- Joined: Thu Sep 20, 2007 1:35 pm
Hi Radhu,
am new to this site and as well as am new to the XSLT, i need a help regarding converting CSV file to XML file
here am getting the CSV file from the MQ Queue, the message looks like this
<payload>abc,111,india</payload>
i would like to conver this MQ message into the XML message using the XSLT
expected out should like this :
<?xml version="1.0" encoding="UTF-8"?>
<empdetails><empname>abc</empname><empid>111</empid><empcountry>india<empcountry></empdetails>
it would be a gr8 if you could provide me the XSLT for this,
thanks in advance
am new to this site and as well as am new to the XSLT, i need a help regarding converting CSV file to XML file
here am getting the CSV file from the MQ Queue, the message looks like this
<payload>abc,111,india</payload>
i would like to conver this MQ message into the XML message using the XSLT
expected out should like this :
<?xml version="1.0" encoding="UTF-8"?>
<empdetails><empname>abc</empname><empid>111</empid><empcountry>india<empcountry></empdetails>
it would be a gr8 if you could provide me the XSLT for this,
thanks in advance
-
- Posts: 4
- Joined: Thu Sep 20, 2007 1:35 pm
am totally new to XSL, if you could provide me the XSL it's great, and also please remeber i need the each coloum in seperate tagjkmyoung wrote:Cursed no edit forum.
<xsl:variable name="var" select="tokenize('payload', ',')"/>
like if the input record is like this : ajay,111,india,1000
then am expecting the ajay in <empname>ajay</empname> tag, <empid>111</empid><empcountry>india</empcountry><empsal>1000</empsal>
am expecting the output in the a bove format
thanks in advance
Return to “General XML Questions”
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