xslt / x-path problem

Discussion in 'XML' started by Bart, Sep 4, 2005.

  1. Bart

    Bart Guest

    I'm trying to transform an xml file to another xml file by using xslt.
    for every child node, i need to do some transformations, except for the
    first one, so I can't use a for-each construction.
    Does anyone now the correct x-path expression or another way to work around
    this problem?
    You can find an example of the xml file below
    I also have another question, can give pass an argument to an xslt script?

    tia
    Bart


    <root>
    <child>
    <!--some tags-->
    </child>
    <child>
    <a></a>
    </child>
    <child>
    <a></a>
    </child>
    <child>
    <a></a>
    </child>
    .....
     
    Bart, Sep 4, 2005
    #1
    1. Advertising

  2. Bart

    Joris Gillis Guest

    Hallo Bart,

    Tempore 13:44:57, die Sunday 04 September 2005 AD, hinc in foro {comp.text.xml} scripsit Bart <>:

    > I'm trying to transform an xml file to another xml file by using xslt.
    > for every child node, i need to do some transformations, except for the
    > first one, so I can't use a for-each construction.
    > Does anyone now the correct x-path expression or another way to work around
    > this problem?


    The problem could be solved with this:

    <xsl:for-each select="child[position() &gt; 1]" />

    or you could use the push style:
    Instead of using for-each, you would then use templates.

    <xsl:template match="child">
    Some transformation
    </xsl:template>

    <xsl:template match="root/child[1]"/>

    The last template would make sure that the first child is ignored.

    regards,
    --
    Joris Gillis (http://users.telenet.be/root-jg/me.html)
    Deserta faciunt et innovationem appelant
     
    Joris Gillis, Sep 4, 2005
    #2
    1. Advertising

  3. Bart

    Bart Guest

    "Joris Gillis" <> schreef in bericht
    news:eek:...
    > Hallo Bart,
    >
    > Tempore 13:44:57, die Sunday 04 September 2005 AD, hinc in foro
    > {comp.text.xml} scripsit Bart <>:
    >
    >> I'm trying to transform an xml file to another xml file by using xslt.
    >> for every child node, i need to do some transformations, except for the
    >> first one, so I can't use a for-each construction.
    >> Does anyone now the correct x-path expression or another way to work
    >> around
    >> this problem?

    >
    > The problem could be solved with this:
    >
    > <xsl:for-each select="child[position() &gt; 1]" />
    >
    > or you could use the push style:
    > Instead of using for-each, you would then use templates.
    >
    > <xsl:template match="child">
    > Some transformation
    > </xsl:template>
    >
    > <xsl:template match="root/child[1]"/>
    >
    > The last template would make sure that the first child is ignored.
    >
    > regards,


    Thanks!

    Bart
     
    Bart, Sep 4, 2005
    #3
    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. Stylus Studio
    Replies:
    0
    Views:
    737
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,732
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    648
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    733
    Henry S. Thompson
    Oct 19, 2005
  5. Xh
    Replies:
    0
    Views:
    883
Loading...

Share This Page