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

Re: Strict sequential identity rule?

Subject: Re: Strict sequential identity rule?
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 22 Sep 2005 07:01:51 +1000
identity rule
Replying to all who were interested to have a look at this.

No, the provided code *is not* an identity transform.

It is very close to an identity transform though...


I found this example interesting, because it shows that

   node()

does not match the document node "/" -- *as a match pattern*.

The transformation will start by applying the built-in template rule:

<xsl:template match="*  |  /"  >
  <xsl:apply-templates/>
</xsl:template>


In case the document node has more than one child -- as in the example
provided by Joris, this will apply templates separately
(independently, parallelly) to these children.

Only then the template in the code will be applied (to all these
children) and the result will be producing N different copies (one for
each of the N different children of the document node) of

   descendent-or-self::node() |  following-sibling::node()

for each child of the document node.

So, to be more exact, in case N = 1 the provided code produces
identical results to those of a real identity transform.


For me the interesting part was to be reminded that

    node()

does not match "/"

if used as a match pattern.


Another interesting question is:

How many different templates get selected and applied in the case when
our code is the wellknown identity rule:

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>


Now, we can easily say that the answer is: two templates.

As a consequence, I think that it would be very helpful to have in
XSLT facilities, which provide warning diagnostics whenever a built-in
template rule is invoked, or to turn off built-in template rules at
all. There is something like this in XSelerator.

Probably vendors of XSLT  processors could provide such facilities?

Cheers,
Dimitre Novatchev.




On 9/21/05, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> OK, Dimitre, I give up. I know you've got a rabbit up your sleeve, and I
> can't ferret it out.
>
> I was thinking the catch might be that a node produced by copying can never
> be "identical" to the original, but I can't imagine that's what you had in
> mind.
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx]
> > Sent: 21 September 2005 13:48
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  Strict sequential identity rule?
> >
> > Hi,
> > I think that trying to answer the following question can be
> > interesting and
> > useful for the members of our community.
> >
> >  Is the following statement true or false:
> >
> > "The transformation below is an identity transformation":
> >
> >  <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >       <xsl:output omit-xml-declaration="yes"/>
> >       <xsl:template match="@* | node()">
> >               <xsl:copy>
> >                       <xsl:apply-templates select="@*"/>
> >                       <xsl:apply-templates select="node()[1]"/>
> >               </xsl:copy>
> >               <xsl:apply-templates
> > select="following-sibling::node()[1]"/>
> >       </xsl:template>
> > </xsl:stylesheet>
> >
> >
> > --
> > Cheers,
> > Dimitre Novatchev
> > ---------------------------------------
> > Getting caught is the mother of invention.
>
>


--
Cheers,
Dimitre Novatchev
---------------------------------------
Getting caught is the mother of invention.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.