Jump to content

Using XSLT transform multiple XML statements


welcomemarie

Recommended Posts

If I have multiple XML statements, such as following:<?xml version="1.0" encoding="Windows-1252"?><statement> <stmnt success='ok'>select 'ok' where 1=1 and 2=2</stmnt> <stmnt success='abc'>select 'a'||'b'||'c' where 1=0 or 1=1</stmnt> <stmnt success='yes'>select 'ok' where not exists (select 'mustfail' where 1=0 and 2=0)</stmnt></statement>and I use xsl.copy to transform them into .fo file:"<xsl:template match="*|@*|comment()|processing-instruction()"> <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/></xsl:template>"but after that, I can discover only one of the statements <stmnt success='ok'>select 'ok' where 1=1 and 2=2</stmnt> can be processed. Do you have any idea for processing multiple XML statement? Thanks!

Link to comment
Share on other sites

If we assume the text() template copies the text, doing nothing else, I don't think you should be seeing anything but the text... unless there are far more templates, which I don't see however.If in addition to your template you create a template like

<xsl:template match="stmnt">...</xsl:template>

it should process every stmnt element in the stylesheet.

Link to comment
Share on other sites

If we assume the text() template copies the text, doing nothing else, I don't think you should be seeing anything but the text... unless there are far more templates, which I don't see however.If in addition to your template you create a template like
<xsl:template match="stmnt">...</xsl:template>

it should process every stmnt element in the stylesheet.

Actually, I only need the text because I have software application which can execute text like "select 'ok' where 1=1 and 2=2" directly. After the execution the result is 'OK'. But the whole process only can run one <stmnt>....</stmnt> once. I expect to see all the result of the statment. <stmnt success='ok'>select 'ok' where 1=1 and 2=2</stmnt> <stmnt success='abc'>select 'a'||'b'||'c' where 1=0 or 1=1</stmnt> <stmnt success='ok'>select 'ok' where not exists (select 'mustfail' where 1=0 and 2=0)</stmnt> Thanks!
Link to comment
Share on other sites

I'm still not sure exactly what is the resulting markup/text you desire, but if it's plain text containing the text of all "stmnt" elements, then

<xsl:template match="stmnt"><xsl:value-of select="."/></xsl:template>

Is the only template you need. You can even remove the one you have already.If it's anything else, please give a more concreate example of what is the result you want to get.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...