[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: match="*:style"

Subject: Re: match="*:style"
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 20 May 2009 10:12:51 -0400
Re:  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>


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.          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@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.