copying all attributes in XSLT

Discussion in 'XML' started by R, Mar 10, 2005.

  1. R

    R Guest

    Hello everybody.

    I've got my XML file with 'field' node .

    Field is transformed with XSLT into paragraph tag in XHTML.

    But. A programmer can add various attributes to <field> node, eg.
    someone can add 'onclick', 'onmouseover', 'style', 'class', 'align'
    attributes and so on. I want to copy all the attributes from <field>
    to <p>.
    But field has also two attributes that can't be copied: 'id' and
    'number'.

    And the final question ;-):
    How to copy all the attributes without 'id' and 'number' ones?

    thanks in advance for any help
    best regards
    R
    R, Mar 10, 2005
    #1
    1. Advertising

  2. R

    Joris Gillis Guest

    Tempore 18:37:57, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit R <>:

    > And the final question ;-):
    > How to copy all the attributes without 'id' and 'number' ones?

    <xsl:copy-of select="@*[not(self::id or self::number)]"/>

    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    "Quot capita, tot sententiae" - Terentius , Phormio 454
    Joris Gillis, Mar 10, 2005
    #2
    1. Advertising

  3. R wrote:


    > How to copy all the attributes without 'id' and 'number' ones?


    <xsl:template match="field">
    <p>
    <xsl:copy-of select="@*[local-name() != 'id' and local-name() !=
    'number']" />
    <xsl:apply-templates />
    </p>
    </xsl:template>

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 10, 2005
    #3
  4. "Joris Gillis" <> writes:

    > Tempore 18:37:57, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit R <>:
    >
    > > And the final question ;-):
    > > How to copy all the attributes without 'id' and 'number' ones?

    > <xsl:copy-of select="@*[not(self::id or self::number)]"/>
    >



    You have to use name()!='id' rather than not(self::id) as self::id
    selects elements not attributes.

    David
    David Carlisle, Mar 10, 2005
    #4
  5. R

    Joris Gillis Guest

    Tempore 23:15:34, die Thursday 10 March 2005 AD, hinc in foro {comp.text.xml} scripsit David Carlisle <>:

    >> > And the final question ;-):
    >> > How to copy all the attributes without 'id' and 'number' ones?

    >> <xsl:copy-of select="@*[not(self::id or self::number)]"/>
    >>

    >
    > You have to use name()!='id' rather than not(self::id) as self::id
    > selects elements not attributes.


    If that is true - and I do not doubt that you're right - then I've been posting non-working code for months:-(
    Yet another bug in my XSLT processor (it select attributes and element in the 'self' axis), I should really consider moving to another...

    Thanks for pointing it out.

    regards,
    --
    Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
    Gaudiam omnibus traderat W3C, nec vana fides
    Joris Gillis, Mar 11, 2005
    #5
    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. Martin Plantec
    Replies:
    3
    Views:
    568
    Martin Plantec
    Oct 28, 2005
  2. Dennis Benzinger

    Copying xml declaration with XSLT

    Dennis Benzinger, Jul 13, 2006, in forum: XML
    Replies:
    5
    Views:
    1,397
    Dennis Benzinger
    Jul 18, 2006
  3. red

    Copying attributes

    red, Jul 20, 2005, in forum: Python
    Replies:
    7
    Views:
    304
    Bengt Richter
    Jul 24, 2005
  4. Wizfrog
    Replies:
    5
    Views:
    2,270
    Joe Kesselman
    Jul 14, 2007
  5. hisachu
    Replies:
    0
    Views:
    1,523
    hisachu
    Sep 1, 2010
Loading...

Share This Page