Question: xml to csv via XSLT

Q

quant

Guys,

I'm using XSLT to translate a XML file with the following structure to
CSV.

<AAA>
<BBB>
<CCC>
<BBB>
</BBB>
</CCC>
</BBB>
</AAA>

How do I specify a template to work on only the second level <BBB> but
not the deepest <BBB>?

I have to admit that this is my 2nd day using XSLT so this may sound
stupid.

-qt-
 
M

Martin Honnen

quant wrote:

I'm using XSLT to translate a XML file with the following structure to
CSV.

<AAA>
<BBB>
<CCC>
<BBB>
</BBB>
</CCC>
</BBB>
</AAA>

How do I specify a template to work on only the second level <BBB> but
not the deepest <BBB>?

You could use
<xsl:template match="AAA/BBB">
for instance to have a template for all <BBB> elements being a child of
an <AAA> element.
Or perhaps even
<xsl:template match="/AAA/BBB">
to have a template for all <BBB> elements being a child of the <AAA>
root element.
 
P

Peter Flynn

Martin said:
quant wrote:



You could use
<xsl:template match="AAA/BBB">
for instance to have a template for all <BBB> elements being a child of
an <AAA> element.
Or perhaps even
<xsl:template match="/AAA/BBB">
to have a template for all <BBB> elements being a child of the <AAA>
root element.

Or (looking at it another way), match="BBB[not(descendant::BBB)]" which
means any BBB provided it does not contain another BBB somewhere deeper.

///Peter
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top