xsl-list
[Top] [All Lists]

RE: Re: [xsl] Replace function with <> characters?

2009-01-06 04:35:14
 

Thanks - My input is actually something like:

<x> <z> 3 </z> </x>

So it should be valid XML, but I need to transform the 
<>-characters of the z-tag (only the z-tag) to "& l t ;" and 
"& g t ;" so what the browser sees in the end is:

<x>  & l t ;z & g t ; 3 & l t ; / z & g t ; </x>

The reason I need to do this is that z-tag is actually to be 
passed as a string to javascript function which will generate 
html for a tooltip where the z-tag then again should be 
showing with <>.

Do I make myself clear :)

Yes, I was beginning to suspect this was your misunderstanding.

XSLT does not see the markup in your lexical XML. It sees a tree of nodes.
There are no angle brackets in any of the nodes. Your sample (ignoring the
whitespace) will create a tree of four nodes:

* an unnamed document node

* an element named x

* an element named z

* a text node whose string-value is "3".

One way of achieving what you want is to use saxon:serialize:

<xsl:template match="x">
  <x>
    <xsl:value-of select="saxon:serialize(z)"/>
  </x>
</xsl:template>

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--