You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Pa...@lotus.com on 2001/02/21 21:48:53 UTC
Re: text() selection problem.
Anders,
Two problems here. First off you need to change the following:
<test headline="preceding-sibling::text()"/>
to
<test headline="{preceding-sibling::text()}"/>
Without the {}'s around your expression you'll just get the text;
"preceding-sibling::text()"
This is cuz you're creating a Literal Result Element which needs to
utilize Attribute Value Template to set attribute values. AVT are specified
with {}'s.
Once {}'s are added you should not have trouble using [1] to specify
which text node out of the nodeset you want. The trick here is to
remember that the preceding-sibling nodeset is indexed in reverse
document order, thus requiring [1]. Given your original xml source tree
the following stylesheet should produce what you're after.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version
="1.0">
<xsl:template match="page">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="e2">
<test headline="{preceding-sibling::text()[1]}"/>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
Paul
"Anders Janmyr"
<anders.janmyr@n To: <xa...@xml.apache.org>
etpuls.nu> cc: (bcc: Paul Dick/CAM/Lotus)
Subject: text() selction problem.
02/20/2001 03:37
AM
Please respond
to xalan-dev
Hello,
I don't know if this is a bug so I'll just describe my problem.
I'm Using Windows NT and Xalan-J-2.0.0.
Im trying to convert a page that looks like this:
<page>
Text for element 1.
<e1>Element 1</e1>
Text for element 2.
<e2>Element 2</e2>
</page>
with this stylesheet rule:
<xsl:template match="e2">
<test headline="preceding-sibling::text()"/>
</xsl:template>
The result is:
<test headline=" Text for element 1. "/>
What I would expect is the the second text, something like this:
<test headline="Text for element 2."/>
I have also had problems when using text()[n] addressing in the
stylesheets.
Are there problem with the text() node?
Any help is appreciated.
Anders