[Home] [By Thread] [By Date] [Recent Entries]
hi group,
I have a problem with understanding why a transform of my stopped working. I found a solution, but I am not sure what the right way to solve it is. I made a simplified example to show the problem. Input file: <doc> <p><Char>hello</Char><Char> there</Char></p> </doc> I started with a stylesheet like this, in which I process content twice, in the normal way (stylesheet is input document as well): <?xml version="1.0" encoding="UTF-8"?> <xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs xsl"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" /> <xsl:template match="/">
<document>
<xsl:apply-templates/>
</document>
</xsl:template> <xsl:template match="p">
<xsl:variable name='blip'>
<xsl:apply-templates />
</xsl:variable><xsl:apply-templates select='$blip' mode='pass2' /> </xsl:template> <xsl:template match="Char">
<char><xsl:apply-templates /></char>
</xsl:template> <xsl:template match='char' mode='#all'>
<c><xsl:apply-templates /></c>
</xsl:template>
</xsl:transform>In pass 1 the Char elements are renamed to char, in pass2 the char elements are renamed to c. Simple and works. The (expected) output is <?xml version="1.0" encoding="utf-8"?> <document xmlns="http://www.w3.org/1999/xhtml"> <c>hello</c> <c> there</c> </document> However, it stops to work when I add a default namespace: <?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs xsl">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />etcetera. The char-match-template now does not fire and the result is <?xml version="1.0" encoding="utf-8"?> <document xmlns="http://www.w3.org/1999/xhtml"> hello there </document> Presumably, the document node in de variable inherits the new default namespace. What is the best way to fix this? I got it working again changing the match on "char" to "*:char" but there must be better ways. regards, Ruud
|

Cart



