AW: Re: [xsl] match="*:style"

Subject: AW: Re: [xsl] match="*:style"
From: Merico Raffaele <raffaele.merico@xxxxxxx>
Date: Mon, 25 May 2009 15:56:17 +0200
Dear Ken

Many thanks for your answer. I was away for a few days.

Today I added a <xsl:message/> just after the
<xsl:template match="*:style[empty(./*) and normalize-space(./text()) eq

You will not believe it, but any @style attribute in the XHTML input was
matched with the above expression.

As you advised me then I changed the condition part
"normalize-space(./text()) eq ''"

With the effect, that now no @style attribute is matched anymore.
I do not understand the difference ...

Cheers Raffaele

-----Urspr|ngliche Nachricht-----
Von: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
Gesendet: Mittwoch, 20. Mai 2009 16:13
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: [?? Probable Spam] Re: [xsl] match="*:style"

At 2009-05-20 15:34 +0200, Merico Raffaele wrote:
>Dear Community
>I process HTML/XHTML files passed as input to my XSLT stylesheet. I'm
>working with SaxonB
>In order to catch the <style/> tag in the HTML/XHTML input file I defined
>the following match-rule.
><xsl:template match="*:style[empty(./*) and normalize-space(./text()) eq

Your use of "./" is redundant in the above, and I'm not in the
practice of addressing text() nodes directly.  I would have used:

    [not(*) and not(normalize-space())]

Alternatively, if I wasn't worried about white-space, just
[not(node())] would test for no child nodes of the element.

>   <xsl:element name="{node-name(current())}"

Use <xsl:copy/> to achieve the above.

>     <xsl:apply-templates select="@*"/>
>       <xslo:value-of select="' '"/>

Are you using namespace aliasing?  It happens I use "xslo:" when I
write stylesheets that write stylesheets.  If so I suspect you want:

    <xslo:text><xsl:text> </xsl:text></xslo:text>

>   </xsl:element>
>Now I am surprised that above match applies also to style-attributes (i.e.
>style="border: 1px solid red;").

It depends on how you are catching your attributes ... I see you are
pushing them at your stylesheet:

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

... but if you don't catch them, then their values will be added to
the result tree as text.

>I can imagine that this is caused by the star in the match.

No.  That is explicitly for elements and not attributes because you
have omitted the axis in the location path step.

>I used the star to mask the namespace-prefix in order match style-tags in
>the null and in the XHTML namespace (without prefix).


>Can anybody please explain me why this happens?

I suspect the built-in template rules are catching the attributes you
are pushing at your stylesheet.  But since you aren't showing more of
your stylesheet it is difficult to tell what is happening with your
style attributes because it might be another part of your stylesheet
that is dealing with them.

If you just want to copy attributes, then you need something like
this (untested):

<xsl:template match="*:style[not(*) and not(normalize-space())]">
     <xsl:copy-of select="@*"/>
     <xslo:text><xsl:text> </xsl:text></xslo:text>

... but I'm confused again because of your use of the "xslo:" prefix.

I hope this helps in some way.

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

XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08
Crane Softwrights Ltd.
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread