Hello George!
You're right, following the description of my problem in more detail:
First, I've a XML-File like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Document>
<textNo>text-1</textNo>
</Document>
Processing this with XSL like this snippet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
<!-- Define Text-Modules -->
<xsl:variable name="text-1">This is long text number one.</xsl:variable>
<xsl:variable name="text-2">This is an other very long
text.</xsl:variable>
<xsl:variable name="text-3">This is my third text without
sense.</xsl:variable>
...
<!-- Hard-coded text-module selection -->
<xsl:choose>
<xsl:when test="textNo = 'text-1'">
<xsl:copy-of select="$text-1"/>
</xsl:when>
<xsl:when test="textNo = 'text-2'">
<xsl:copy-of select="$text-2"/>
</xsl:when>
<xsl:when test="textNo = 'text-3'">
<xsl:copy-of select="$text-3"/>
</xsl:when>
</xsl:choose>
I dont like the the hard-coded tests to the value of the element
"textNo", hope there is a way directly to use the <xsl:copy-of> to the
variable with the name, which is the same as the value in the element
"textNo".
Thanks for you suggestions george. Doing the job in two transformation
doesn't please me. Isn't there no way without a processor extension?
Cant believe that... :'(
Hoped there was a way like this:
<xsl:copy-of select="${<xsl:copy-of select='textNo'/>}"/>
Greetings,
Christian
George Cristian Bina schrieb:
Hi Christian,
I think that what you want is to dynamically evaluate the expression
that is in the textNo element, right?
In that case there are two possibilities, one is to do this in two
transformations, one to generate a stylesheet and then apply that
stylesheet on the actual data. The other possibility is to use a
processor extension function like saxon:evaluate for instance. Of
course if the number of expressions is limited you can handle that
with an if (or if you have more expressions eventually with a choose)
as you do right now.
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Christian Haase wrote:
Hi all!
Do you have any ideas how I can code this XSL more beautiful:
<xsl:if test="textNo = 'text-1'" >
<xsl:copy-of select="$text-1"/>
</xsl:if>
In other words: Is there a chance to use the <copy-of> directly with
the value of "textNo", without the <xsl:if> ?
Greetings,
Christian
-------------------------------------
Christian Haase, Hans-Mertens-Str. 37
30655 Hannover, GERMANY
Tel: +49-511-697916 / +49-178-7772617
Fax: +49-511-3948280
ICQ: 307628315
-------------------------------------
--~------------------------------------------------------------------
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>
--~--