Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] How to use the same expression in a match and a select test

From: Sascha Mantscheff <922492@------>
To:
Date: 12/3/2007 2:00:00 PM
I love this list. Thank you all.

Am Montag, den 03.12.2007, 13:57 +0000 schrieb Michael Kay:
> You're using XSLT 2.0 so you can write $NO_BLOCK_ELEMENTS and
> $SAME_ATTRIBUTES as stylesheet functions returning a boolean:
> 
> <xsl:function name="f:is-no-block-element" as="xs:boolean">
>   <xsl:param name="n" as="element()"/>
>   <xsl:sequence select="not(self::blockquote|self::center...)"/>
> </xsl:function>
> 
> match="*[is-no-block-element(.)]"
> 
> Alternatively, many of the elements listed have a schema type of Inline in
> the XHTML schema, so you could refer to them collectively as element(*,
> Inline) if you import the schema.
> 
> The test string-join(@*,'xx') = string-join(current()/@*,'xx') looks wrong -
> it's relying on the order in which attributes are returned by @*, which may
> vary from one element to the next.
> 
> It looks to me as if your code could also benefit from using
> <xsl:for-each-group group-adjacent="...">
> 
> Michael Kay
> http://www.saxonica.com/
> 
> 
> > -----Original Message-----
> > From: Sascha Mantscheff [mailto:922492@xxxxxx] 
> > Sent: 03 December 2007 13:21
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: [xsl] How to use the same expression in a match and 
> > a select test
> > 
> > I have a stylesheet with a template and a for-each statement.
> > Both select their elements by an expression which differs 
> > only in one part from each other.
> > 
> > The template is:
> > 
> > <xsl:template match="*[not(self::blockquote|self::center|self::BODY|
> > self::body|self::div|self::dl|self::dt|self::HEAD|self::head|s
> > elf::HTML|
> > self::img|self::h1|self::h2|self::h3|self::h4|self::h5|self::h6|
> > self::hr|self::html|self::idx:*|self::form|
> > self::mbp:*[not(self::mbp:nu)]|self::mmc:*|self::ol|self::p|se
> > lf::table|
> > self::td|self::th|self::tr|
> > self::ul)][preceding-sibling::node()[1][name()=name(current()) and
> > string-join(@*,'xx') = string-join(current()/@*,'xx')]]"
> > />
> > 
> > The for-each select is:
> > 
> > <xsl:for-each 
> > select="following-sibling::node()[1][not(self::blockquote|
> > self::center|self::BODY|self::body|self::div|self::dl|self::dt|
> > self::HEAD|self::head|self::HTML|self::img|self::h1|self::h2|self::h3|
> > self::h4|self::h5|self::h6|self::hr|self::html|self::idx:*|self::form|
> > self::mbp:*[not(self::mbp:nu)]|self::mmc:*|self::ol|self::p|se
> > lf::table|
> > self::td|self::th|self::tr|self::ul)] [name()=name(current()) and
> > string-join(@*,'xx') = string-join(current()/@*,'xx')]">
> > 
> > How can I reduce the redundancy and use the same expression 
> > in both statements, like in this pseudo code:
> > 
> > <xsl:template
> > match="*[$NO_BLOCK_ELEMENTS][preceding-sibling::node()[1][name
> > ()=name(current()) and $SAME_ATTRIBUTES]]"
> > />
> > 
> > <xsl:for-each select="following-sibling::node()[1][$NO_BLOCK_ELEMENTS]
> > [name()=name(current()) and $SAME_ATTRIBUTES]">


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent