Good morning all,
I have the following xml :
<?xml version="1.0" encoding="UTF-8"?>
<anchor>
<title>Seconde classe</title>
<content>
<P> Hello World, <b>here is a text in bold</b> and this is the rest
of the text</P>
<P> Hello World 2, this is the second paragraph ! <b>here is a text
in bold</b> and this is the rest of the text</P>
</content>
</anchor>
What I want is to remove the <P> and </P>
I try with the following xsl :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mydoctype[<!ENTITY nbsp " ">]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1"
omit-xml-declaration="yes" standalone="yes" indent="yes"/>
<xsl:template match="anchor">
<font class="copy"><b><xsl:value-of select="title" /></b></font><br/>
<xsl:apply-templates select="content"/>
</xsl:template>
<xsl:template match="content">
coucou
<xsl:if test="contains(., '<P>')">
coucou2
<xsl:value-of select="substring-before(substring-after(., '<P>'),
'</P>')"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
but it doesn't work either.
Do you have an idea of how I should do it ?
Thanks in advance for your help,
Alexandra
Jake G. - 21 Oct 2003 15:44 GMT
Couldn't you just do a global find/replace within the XML document
itself? Seems simple enough.
- Jake G.
> Good morning all,
>
[quoted text clipped - 42 lines]
> Thanks in advance for your help,
> Alexandra
Christoph Schittko [MVP] - 22 Oct 2003 05:13 GMT
You need an XSLT that copies all the content of <P> element. Try this:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1" omit-xml-declaration="yes"
standalone="yes" indent="yes"/>
<xsl:template match="anchor">
<font class="copy"><b><xsl:value-of select="title" /></b></font><br/>
<xsl:apply-templates select="content"/>
</xsl:template>
<xsl:template match="content">
kuckuck
<xsl:for-each select="P">
<xsl:apply-templates />
</xsl:for-each>
kuckuck2
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Signature
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
> Couldn't you just do a global find/replace within the XML document
> itself? Seems simple enough.
[quoted text clipped - 47 lines]
> > Thanks in advance for your help,
> > Alexandra