xsl-list
[Top] [All Lists]

Re: [xsl] Match nodes searching for attributes in children

2010-01-17 21:22:31
At 2010-01-18 04:09 +0100, cvergara(_at_)zedat(_dot_)fu-berlin(_dot_)de wrote:
Hello Ken and Gerrit,

thanks for your debugging tips. I was making the experiments in a small
test file, not in my development files, so I know there are no mistakes
nor missing namespace prefixes in elements. One curious thing though, I
noticed that my xslt processor (xalan 2.7.1 and the one included in java)
are not able to match attributes. Other people claim something like this
is possible:

<xsl:template match="@attr">
or even:
<xsl:template match="@*">

Even the default template will not match them. An empty stylesheet will
copy only the text elements.

It only copies the text nodes ... it does not copy elements, it acts on element children (not on element attributes).

It will be difficult for me to get help if
the processors behave differently.

They do not behave differently in this regard.

Again you are missing some basic knowledge of XSLT and assuming that things are broken.

Attributes are matched when they are pushed at your stylesheet, but when you use <xsl:apply-templates/> without a select= attribute then only child elements are pushed, not attributes, because in the XPath data model attributes are not children of an element.

When you want to have this acted on:

  <xsl:template match="@attr">

... then somewhere in your stylesheet you will need to have used something like:

  <xsl:apply-templates select="@*"/>

or

  <xsl:apply-templates select="@attr"/>

Please try and find some basic instruction in XSLT to understand what is going on within the processor. Asking volunteers for help with a specific problem you are having will get a more receptive response than asking volunteers to teach you the language.

And, as Gerrit says, use Saxon ... it is more robust than Xalan. And XSLT 2.0 supports a more feature-rich version of functionality than XSLT 1.0.

I hope this helps.

. . . . . . . . . . . . . Ken

p.s. and, Gerrit, *both* of you appear to be in CEST according to your time stamps and *both* of you should be in bed by now! It is past *my* bed time and I'm in EST!

--
UBL and Code List training:      Copenhagen, Denmark 2010-02-08/10
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
XSLT/XQuery/XPath training:   San Carlos, California 2010-04-26/30
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>
--~--