[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Node Values Contain Entities: Can't Get Correct Output

Subject: Node Values Contain Entities: Can't Get Correct Output
From: B K Partridge <derangedwombat@xxxxxxxxx>
Date: Sun, 31 Aug 2003 15:03:21 -0700 (PDT)
get node value
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.