Re: Catch a Character ...

Michael Ludwig <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>
Claus Kick schrieb:
>
> I am trying to catch a special character with the following style sheet:
>
> <xsl:param name="specChar" select="'\u201C'" />

That's the Java syntax. Doesn't work in XML. Use a numerical character
reference as per the XML spec.

   <xsl:param name="specChar" select="'&#x201C;'" /> in hex, or
   <xsl:param name="specChar" select="'&#8220;'" /> in decimal

>     <xsl:output indent="yes" method="xml"/>
>     <xsl:strip-space elements="*"/>
>
>     <xsl:template
> match="CATALOOM-OPENENGINE/PRODUCTS/PRODUCT/PRODUCTREVISION">

Not knowing your input, I can't be sure, but simply doing
match="PRODUCTREVISION" would probably be specific enough.

>     <xsl:variable name="primKey2">
>             <xsl:value-of select="substring-before(@primarykey, '/')"/>
>     </xsl:variable>

That's a very bad way of getting the value. Instead, use:

   <xsl:variable name="primKey2"
     select="substring-before(@primarykey, '/')"/>

Your version creates a so-called "result tree fragment" (RTF), which is
inefficient and cumbersome.

>      <xsl:for-each select="FEATURE/VALUE">
>         <xsl:variable name="cdata">
>             <xsl:value-of select="FEATURE/VALUE/text()"/>
>         </xsl:variable>

Same story here. In addition, avoid using the text() node test to get
the string value:

   <xsl:value-of select="FEATURE/VALUE"/>

But are you sure your input is FEATURE/VALUE/FEATURE/VALUE?

> How do I have to mask a unicode char inside a string inside  a
> stylesheet?

As shown above. Or simply as a literal, if you're using a Unicode
encoding and your input device and display support that character.

You can learn XSLT by reading XSL-List at Mulberrytech or any good book
in XSLT, like, for starters, the Pocket Guide by Evan Lenz.

-- 
Michael Ludwig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.