xsl:text element?

M

Mike Kamermans

I'm having difficulty XSL tranforming some XML of the form <some_element>
<jis>1234</jis></some_element> into the xhtml form <img
src="jis/1234.gif"/>

My initial idea was to use the following XSL:

<xsl:text><img src="jis/</xsl:text><xsl:value-of select"./jis/text()"/>
<xsl:text>.gif"/></xsl:text>

But when I run this, I get the error that "src may not contain a <
symbol" (I run this in the XSLT engine that comes with the Exchanger XML
editor v2, which uses Xerces 2.6.2 and Saxon 6.5.2). I must admit being
slightly confused... am I using <xsl:text> wrong, or should this work for
all intents and purposes?


Mike Kamermans
 
J

Joris Gillis

Hi,

use:
<img src="jis/{./jis/text()}.gif"/>
or:
<img>
<xsl:attribute name="src">jis/<xsl:value-of
select="./jis/text()"/>.gif</xsl:attribute>
</img>

regards,
 
D

David Carlisle

My initial idea was to use the following XSL:

<xsl:text><img src="jis/</xsl:text><xsl:value-of
select"./jis/text()"/>

XSLT has to be well formed XML, you can never have element markup inside
an attribute in XML so that would be rejected by the XML parser before
XSLT started.

if you fix the attribute so that XSLt does see the file, the XSLT engine
will tell you that you can't have result elements inside xsl:text (only
text)

Use

<img src="jis/{jis}.gif"/>

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top