A
A. Wiebenga
Hi all!
I am currently involved in a project in which I am supposed to write a
XSLT-transformation sheet for some XML data.
I will outline the situation first:
I've got one large XML file which is roughly build up like this:
<forms>
<subform>
<questions>
<question>
<text>ABC count</text>
<number=1010>
<answer>
<value>1</value>
</answer>
</question>
<question>
<text>ABC score</text>
<number=1020>
<answer>
<value>10</value>
</answer>
</question>
<question>
<text>DEF score</text>
<number=1030>
<answer>
<value>3</value>
</answer>
</question>
<question>
<text>DEF count</text>
<number=1040>
<answer>
<value>2</value>
</answer>
</question>
</questions>
</subform>
</forms>
....etc...
I want this data to be in a table like this:
TYPE SCORE COUNT
ABC 10 1
DEF ...etc.
The problem being that not all of the question/answer tags are needed.
So I need to loop through all question-nodes (roughly 100)and extract
only a few elements for the table. The needed tags are recognisable
because there "number" is above 1000. Furthermore, there are only 3
seperate values per type (I've used only 2 for my example).
I've started as follows:
First I loop through all the question-nodes via a <xsl:for-each> loop.
I then test each question-node for a "number"-tag that exceeds 1000 (I
only need these nodes for my table).
These two steps bring me at the point where I can fill my table. It's
at this point that I am stuck. I can't figure out how I am supposed to
know when to start a new row. To my knowledge, it's not possible to
keep track of a counter in XSLT (if this were possible, I could just
count the number of columns I'd have filled). I've tried using
<xsl:when> statements to start a new row using hardcoded borders (for
example: I know the row ends after a ABC->COUNT node), but this is not
possible because of the nested structure of XML.
I don't know what to do now, so please help..
Thanks in advance,
Alke Wiebenga
I am currently involved in a project in which I am supposed to write a
XSLT-transformation sheet for some XML data.
I will outline the situation first:
I've got one large XML file which is roughly build up like this:
<forms>
<subform>
<questions>
<question>
<text>ABC count</text>
<number=1010>
<answer>
<value>1</value>
</answer>
</question>
<question>
<text>ABC score</text>
<number=1020>
<answer>
<value>10</value>
</answer>
</question>
<question>
<text>DEF score</text>
<number=1030>
<answer>
<value>3</value>
</answer>
</question>
<question>
<text>DEF count</text>
<number=1040>
<answer>
<value>2</value>
</answer>
</question>
</questions>
</subform>
</forms>
....etc...
I want this data to be in a table like this:
TYPE SCORE COUNT
ABC 10 1
DEF ...etc.
The problem being that not all of the question/answer tags are needed.
So I need to loop through all question-nodes (roughly 100)and extract
only a few elements for the table. The needed tags are recognisable
because there "number" is above 1000. Furthermore, there are only 3
seperate values per type (I've used only 2 for my example).
I've started as follows:
First I loop through all the question-nodes via a <xsl:for-each> loop.
I then test each question-node for a "number"-tag that exceeds 1000 (I
only need these nodes for my table).
These two steps bring me at the point where I can fill my table. It's
at this point that I am stuck. I can't figure out how I am supposed to
know when to start a new row. To my knowledge, it's not possible to
keep track of a counter in XSLT (if this were possible, I could just
count the number of columns I'd have filled). I've tried using
<xsl:when> statements to start a new row using hardcoded borders (for
example: I know the row ends after a ABC->COUNT node), but this is not
possible because of the nested structure of XML.
I don't know what to do now, so please help..
Thanks in advance,
Alke Wiebenga