[XSL] how could I know node attributes???

Discussion in 'XML' started by jaloplo@gmail.com, Oct 17, 2006.

  1. Guest

    Hi,

    I'm having a big problem cause I need to write attributes values
    without knowing the name of these attributes. For example, my xml file
    is like this:

    <element id="1" name="pepe" field1="1"/>
    <element id="2" name="pepe"/>
    <element id="3" name="pepe" field1="a" field4="2"/>
    <element id="4" name="pepe" field3="s" field4="r"/>

    And I have to group these elements by 'name' attribute, and then write
    all the field1 values, all the field2 values, all the field3 values,
    etc., and I don't know how many fieldx values are.

    The result file must be something like that:

    Name | Observation
    pepe | field1 1
    pepe | field1 a
    pepe | field3 s
    pepe | field4 2
    pepe | field4 r

    How can I group nodes by attributes??? Or how can I know the attributes
    of one node???

    Thanks!!!!
    , Oct 17, 2006
    #1
    1. Advertising

  2. wrote:

    > <element id="1" name="pepe" field1="1"/>
    > <element id="2" name="pepe"/>
    > <element id="3" name="pepe" field1="a" field4="2"/>
    > <element id="4" name="pepe" field3="s" field4="r"/>
    >
    > And I have to group these elements by 'name' attribute, and then write
    > all the field1 values, all the field2 values, all the field3 values,
    > etc., and I don't know how many fieldx values are.


    The XPath
    @*
    selects all attribute nodes, the XPath
    @*[starts-with(local-name(), 'field')]
    selects all attribute nodes where the local name starts with the string
    'field' (e.g. 'field1', 'field2', 'fieldsomething').

    See
    <http://www.jenitennison.com/xslt/grouping/index.xml>
    for grouping.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 17, 2006
    #2
    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. Replies:
    0
    Views:
    1,448
  2. CB
    Replies:
    1
    Views:
    591
    Johannes Koch
    Oct 2, 2003
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,423
    Dimitre Novatchev
    Aug 24, 2006
  4. sangram
    Replies:
    16
    Views:
    1,984
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    229
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page