xsl-list
[Top] [All Lists]

Re: Node Values Contain Entities: Can't Get Correct Output

2003-08-31 18:48:40
At a quick glance(didnt look to deep into it. If this doesnt work tell me and ill look deeper) you have 50% right in the first attempt and 50% right in the second. You need to have this as the source...


<![CDATA[&amp;middot]]>

and this is the processing...

<xsl:value-of select="//m:mo" disable-output-escaping="yes"/>

Let me know if this doesnt work and Ill look deeper into it...

M.David


From: B K Partridge <derangedwombat(_at_)yahoo(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
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>&middot;</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 "&middot;" I get, a mid-dot.  That's cool.

But I don't want a mid-dot in my document.  I want
this: &middot

The first thing I tried, was changing the input to
&amp;middot;  Well, that unfortunately didn't work.
If I started with &amp;middot; I ended up with
&amp;middot and NOT &middot; -- for some reason, which
I just don't understand.

So, then, I tried this as the input:

<m:mo><[!CDATA [ &middot; ]]></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="'&amp;'" />
        <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


XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>