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

RE: first question to the list: contains

Subject: RE: first question to the list: contains
From: "Jared Stein" <STEINJA@xxxxxxxx>
Date: Fri, 02 Nov 2007 23:22:32 -0600
RE:  first question to the list: contains
Scott, thanks for the great explanation.  Though it's disappointing (as
I need to check for _any_ Japanese character to make this test
effective), at least it makes sense. 

Luckily, it's not out of the question for me to add an additional
element or attribute to the XML files--this is something I could do
pretty easily with a search and replace, and would in fact add to the
value of the XML.

Date: Fri, 2 Nov 2007 17:39:29 -0500
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: "Scott Trenda" <Scott.Trenda@xxxxxxxx>
Subject: RE:  first question to the list: contains
Message-ID:
<DA088AB42E20F841A1CDBDD0564B8E2D0530136D@xxxxxxxxxxxxxxxxxxxx>

The problem here is that XSLT operates on the expanded infoset of the
parsed XML file, and is blind to the literal text that created that
infoset. That is, if your XML file includes those characters (e.g.
<wording>123&#12360;456</wording>), then your XSLT won't see the
entity's literal text (&amp;#12360;), it'll see that entity's value
(the
Japanese character). Likewise, if you use an entity in your XSLT
stylesheet, then the processor will use the value of that entity,
rather
than the text you used to represent it.

So, if you know the characters that you need to check for, you can do
something like this:
<xsl:if test=3D"translate(wording,
'&#12360;&#12361;&#12362;&#12363;&#12364;&#12365;&#12366;&#12367;&#12368
;&#12369;&#12370;&#12371;&#12372;&#12373;', '') !=3D string(wording)">
	<xsl:attribute name=3D"class">
		<xsl:text>fs front jpns</xsl:text>
	</xsl:attribute>
</xsl:if>

This test just wipes out the numerals in question, and checks to see
if
its string-value is any different than before.

I guessed at the entity code numbers here - you'll have to look up
their
actual ones and substitute them in. If you're checking for Japanese
numerals, I'm guessing you can narrow the check down to ichi
(&#12360;),
ni (&#12361;), san (&#12362;), yon (&#12363;), go (&#12364;), roku
(&#12365;), shichi (&#12366;), hachi (&#12367;), kyuu (&#12368;), juu
(&#12369;), hyaku (&#12370;), sen (&#12371;), man (&#12372;), and oku
(&#12373;).

~ Scott

Jared Stein

   Director of Instructional Design Services
   Utah Valley State College, MS 149
 
Teaching w/ Technology Idea Exchange 2008: The Open Conference
   Submit your presentation proposal now! http://www.ttix.org

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-2007 All Rights Reserved.