0
votes

I have a XML hierarchy just like this one:

    <main-parent>
      <child>
        <element1>...</element1>
        <element2>...</element2>
      </child>
      <child>
        <element1>...</element1>
        <element2>...</element2>
      </child>
      <child>
        <element1>...</element1>
        <element2>...</element2>
      </child>
    </main-parent>

In XSL, I'm trying to retrieve element1 and element2 tag names and make them table-headers(th) in a table. How can I do this? Using xsl:for-each in above example, on the main-parent/child, there will be 6 th's(2 in every child element) and that's not what I want. I just want to get element1 and element2 tag names. Inside xsl:template I am using xhtml(html, head and body elements) and creating the table in body element with table tag(just like in any html).

1

1 Answers

0
votes

You can always use a positional predicate e.g. /main-parent/child[1]/* to select only the child elements of the first child element or (XSLT 2 and later) /main-parent/child[1]/*/local-name() to select their names as a sequence of strings directly.