Reparsing existing XML element

T

timbrigham

Forgive me if this has been asked before, but I haven't found anything
useful in my searches.
I have an XML document generated from an external program that I can't
change the output format on. Most of the output is great, but one
specific element, needs to be parsed into about a dozen smaller
elements based on a delimiter. I'm unsure how to do this effectively.
Any help would be much appreciated.
 
P

Peter Flynn

Forgive me if this has been asked before, but I haven't found anything
useful in my searches.
I have an XML document generated from an external program that I can't
change the output format on. Most of the output is great, but one
specific element, needs to be parsed into about a dozen smaller
elements based on a delimiter. I'm unsure how to do this effectively.
Any help would be much appreciated.

What language do you need to do this in?
In XSLT, have a look at substring-before and recursive templates.

///Peter
 
T

timbrigham

I was looking at doing it in XSLT, but open to other options.
Thanks for the input.
 
J

JAPISoft

Hello Peter,

Your problem is that you have a text block in your XML output that
should be transformed to XML elements ? And you need to scan each
separator for extracting the whole data ? Is it what you mean ?

XSLT was not really adapted to scan text values, but I think you could
try with a named template using a parameter.

Here a sample code :

<xsl:template name="parsing">
<xsl:param name="line"></xsl:param>
<xsl:if test="$line<>''">
<xsl:call-template name="parsing">
<xsl:with-param name="line">
<xsl:value-of select="substring-after( $line, 'YOUR_SEP' )"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>


Best regards,

A.Brillant
EditiX - XML Editor and XSLT Debugger
http://www.editix.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top