Mixed content handling

M

mr.per.bergman

I have an XML file with mixed content like this:

<sometag>

some text...
some text...

<anothertag>
other text...
other text...
</anothertag>

some more text...
</sometag>

I have a stylesheet which processes <sometag>, which
in turn processes <anothertag>.

My problem is that my stylesheet will skip the text after
"</anothertag>. Is there a way to do this?


Per
 
P

Peter Flynn

I have an XML file with mixed content like this:

<sometag>

some text...
some text...

<anothertag>
other text...
other text...
</anothertag>

some more text...
</sometag>

I have a stylesheet which processes <sometag>, which
in turn processes <anothertag>.

My problem is that my stylesheet will skip the text after
"</anothertag>. Is there a way to do this?

Without seeing what your XSL says, it's not possible to answer.

But at a wild guess, you're not using <xsl:apply-templates/> in the
template which handles <sometag>.

///Peter
 
P

Pejb

Sorry about that, here is a snippet:

--------------------------------------------------------------------------
<xsl:template match="sometag">
<xsl:value-of select="text()"/>
<xsl:apply-templates select="anothertag"/>
</xsl:template>

<xsl:template match="anothertag">
<xsl:value-of select="text()"/>
<xsl:apply-templates select="anothertag"/>
</xsl:template>
 
J

Joris Gillis

Tempore 00:02:57 said:
<xsl:template match="sometag">
<xsl:value-of select="text()"/>
<xsl:apply-templates select="anothertag"/>
</xsl:template>

<xsl:template match="anothertag">
<xsl:value-of select="text()"/>
<xsl:apply-templates select="anothertag"/>
</xsl:template>

--------------------------------------------------

Change that to:
<xsl:template match="sometag">
<xsl:apply-templates select="anothertag|text()"/>
</xsl:template>

<xsl:template match="anothertag">
<xsl:apply-templates select="anothertag|text()"/>
</xsl:template>




regards,
 
P

Peter Flynn

Pejb said:
Sorry about that, here is a snippet:

--------------------------------------------------------------------------
<xsl:template match="sometag">
<xsl:value-of select="text()"/>
<xsl:apply-templates select="anothertag"/>
</xsl:template>

<xsl:template match="anothertag">
<xsl:value-of select="text()"/>
<xsl:apply-templates select="anothertag"/>
</xsl:template>

If you want everything output that should be

<xsl:template match="sometag">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="anothertag">
<xsl:apply-templates/>
</xsl:template>

///Peter
 
P

Pejb

Peter said:
If you want everything output that should be

<xsl:template match="sometag">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="anothertag">
<xsl:apply-templates/>
</xsl:template>

///Peter

Thanks!
This works perfectly now.

Per
 

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,000
Messages
2,570,252
Members
46,848
Latest member
CristineKo

Latest Threads

Top