Patterns in XSL - once again

Discussion in 'XML' started by Soren Kuula, Mar 17, 2005.

  1. Soren Kuula

    Soren Kuula Guest

    Hi,

    In XSLT1.0, are these two match expressions not supposed to match the
    same nodes:

    child::foo

    and

    foo

    ?

    As I can read the grammar for match expression in the spec, child:; is
    implied when there is no / or // at the beginning, and no exlpicit axis.

    -- but my xsltproc behaves differently with and without the child:: !

    Where is the bug.. ?

    Soren
     
    Soren Kuula, Mar 17, 2005
    #1
    1. Advertising

  2. Soren Kuula <> writes:

    > Hi,
    >
    > In XSLT1.0, are these two match expressions not supposed to match the
    > same nodes:
    >
    > child::foo
    >
    > and
    >
    > foo
    >
    > ?
    >
    > As I can read the grammar for match expression in the spec, child:; is
    > implied when there is no / or // at the beginning, and no exlpicit axis.
    >
    > -- but my xsltproc behaves differently with and without the child:: !
    >
    > Where is the bug.. ?


    somewhere that you haven't shown us. What different behaviour do you
    see?

    child::foo and foo are equivalent in XPath expressions an in XSLT match
    patterns.


    David
     
    David Carlisle, Mar 17, 2005
    #2
    1. Advertising

  3. Soren Kuula

    Soren Kuula Guest

    Hi,

    All right I neglected the example. Here is one:

    Input doc:
    [dongfang@granada xslt-examples]$ cat position-fun.xml
    <?xml version='1.0'?>
    <warehouse>
    <item name="foo">
    <country>Argentina</country>
    </item>
    <item name="bar">
    <country>Brazil</country>
    </item>
    <item name="baz">
    <country>China</country>
    </item>

    1st stylesheet:
    [dongfang@granada xslt-examples]$ cat position-fun21.xsl
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:eek:utput method="xml" indent="yes"/>

    <xsl:template match='warehouse'>
    <position-experiment>
    <first-try>
    <xsl:apply-templates select='item/country | text()'/>
    </first-try>
    </position-experiment>
    </xsl:template>

    <xsl:template match='country[1]'>
    <first-country>
    (with "first", we mean: <xsl:value-of select="position()"/>)
    <xsl:copy-of select='.'/>
    </first-country>
    </xsl:template>

    <xsl:template name="notfirst" match='country'>
    <xsl:copy-of select='.'/>
    </xsl:template>
    </xsl:stylesheet>

    Output:
    [dongfang@granada xslt-examples]$ xsltproc position-fun21.xsl
    position-fun.xml
    <?xml version="1.0"?>
    <position-experiment>
    <first-try>
    <first-country>
    (with "first", we mean: 2)
    <country>Argentina</country></first-country>
    <first-country>
    (with "first", we mean: 4)
    <country>Brazil</country></first-country>
    <first-country>
    (with "first", we mean: 6)
    <country>China</country></first-country>
    </first-try>
    </position-experiment>


    2nd stylesheet: Only difference is addition of child:: in match exp

    [dongfang@granada xslt-examples]$ cat position-fun22.xsl
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:eek:utput method="xml" indent="yes"/>

    <xsl:template match='warehouse'>
    <position-experiment>
    <first-try>
    <xsl:apply-templates select='item/country | text()'/>
    </first-try>
    </position-experiment>
    </xsl:template>

    <xsl:template match='child::country[1]'>
    <first-country>
    (with "first", we mean: <xsl:value-of select="position()"/>)
    <xsl:copy-of select='.'/>
    </first-country>
    </xsl:template>

    <xsl:template name="notfirst" match='country'>
    <xsl:copy-of select='.'/>
    </xsl:template>
    </xsl:stylesheet>

    Output:

    [dongfang@granada xslt-examples]$ xsltproc position-fun22.xsl
    position-fun.xml
    <?xml version="1.0"?>
    <position-experiment>
    <first-try>
    <country>Argentina</country>
    <country>Brazil</country>
    <country>China</country>
    </first-try>
    </position-experiment>
    [dongfang@granada xslt-examples]$

    Some difference there.

    As I get it, they should have been identical??

    Soren
     
    Soren Kuula, Mar 17, 2005
    #3
  4. Soren Kuula

    Soren Kuula Guest

    And:
    [dongfang@granada xslt-examples]$ xsltproc --version
    Using libxml 20606, libxslt 10033 and libexslt 722
    xsltproc was compiled against libxml 20511, libxslt 10033 and libexslt 722
    libxslt 10033 was compiled against libxml 20511
    libexslt 722 was compiled against libxml 20511
     
    Soren Kuula, Mar 17, 2005
    #4

  5. > As I get it, they should have been identical??


    yes, they should.

    David
     
    David Carlisle, Mar 17, 2005
    #5
  6. Soren Kuula

    Soren Kuula Guest

    David Carlisle wrote:
    >>As I get it, they should have been identical??

    >
    > yes, they should.
    >
    > David


    Thanks David,

    Getting confused is not that bad after all then, when what you are
    trying to convince yourself about is wrong....

    Soren
     
    Soren Kuula, Mar 17, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ante Perkovic

    Once again: validating the datagrid

    Ante Perkovic, Jun 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    890
    Ante Perkovic
    Jun 25, 2003
  2. =?Utf-8?B?TWF1cml6aW8gUG9sZXR0bw==?=

    Once logon, the web application returs to login page again

    =?Utf-8?B?TWF1cml6aW8gUG9sZXR0bw==?=, Mar 24, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    325
    Patrick.O.Ige
    Mar 25, 2006
  3. Replies:
    1
    Views:
    3,613
    A. Bolmarcich
    May 27, 2005
  4. crichmon
    Replies:
    4
    Views:
    487
    Mabden
    Jul 7, 2004
  5. Gancy
    Replies:
    4
    Views:
    188
    Rasto Levrinc
    Feb 3, 2005
Loading...

Share This Page