Subject: Re: [xsl] Node Values Contain Entities: Can't Get Correct Output From: "Mark Peterson" <conners_dad@xxxxxxx> Date: Sun, 31 Aug 2003 18:48:40 -0700 |
From: B K Partridge <derangedwombat@xxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Node Values Contain Entities: Can't Get Correct Output Date: Sun, 31 Aug 2003 15:03:21 -0700 (PDT)
I am sorry to ask this. I know this is probably not allowed to ask. But I **can't** figure this out. I have tried for *days*...and I'm not kidding. Someone please take pity on me.
Ahem.
Okay...
I have an xml document with parts like this:
<m:math mode="display"> <m:mrow> <m:mi>tan</m:mi> <m:mfenced> <m:mrow> <m:mn>30</m:mn> <m:mo>·</m:mo> <m:mi>deg</m:mi> </m:mrow> </m:mfenced> </m:mrow> </m:math>
Obviously, when I run this through the processor, in place of "·" I get, a mid-dot. That's cool.
But I don't want a mid-dot in my document. I want this: ·
The first thing I tried, was changing the input to &middot; Well, that unfortunately didn't work. If I started with &middot; I ended up with &middot and NOT · -- for some reason, which I just don't understand.
So, then, I tried this as the input:
<m:mo><[!CDATA [ · ]]></m:mo>
and I tried this as the processing code:
<xsl:template match="m:math"> <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"> <xsl:variable name="amp" select="'&'" /> <xsl:for-each select="descendant::*"> <xsl:choose> <xsl:when test="contains(.,$amp)"> <xsl:variable name="curname" select="name(.)"/> <xsl:element name="{$curname}" namespace="http://www.w3.org/1998/Math/MathML"> <xsl:value-of disable-output-escaping="yes" select="."/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </m:math>
Now, I realize this isn't perfect. For one thing, it doesn't do anything about situations where I have a entity in a node that has attributes - I'm not copying those in the first instance. But there are other things wrong with this that I can't figure out - first of all - it DOESN'T ignore escaping on the value of the node, secondly, it doesn't put the new element in the right namespace even though I have namespace m declared in the stylesheet at the mathML namespace and I specify the namespace AGAIN where I'm attempting to construct the element.
Any help anyone would be kind enough to offer would be greatly greatly appreciated.
Thanks.
</xsl:template>
__________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________ MSN 8: Get 6 months for $9.95/month. http://join.msn.com/?page=dept/dialup
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Node Values Contain Entities:, B K Partridge | Thread | |
[xsl] Node Values Contain Entities:, B K Partridge | Date | |
Month |