Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Help in XSL

Hi All,

I have the following XML...

<mydata>
<question-id>
<id>1</id>
<id>4</id>
<id>2</id>
</question-id>
<questionire>
<question>
<qid>1</qid>
<desc>one</desc>
</question>
<question>
<qid>2</qid>
<desc>Two</desc>
</question>
<question>
<qid>3</qid>
<desc>Three</desc>
</question>
<question>
<qid>4</qid>
<desc>Four</desc>
</question>
</questionire>
</mydata>

Now, I was to fetch desc for each id the question-id and want to put
in a table. ie for above XML, I want
output like

1 One
4 Four
2 Two

Can any one provide the corresponding XSl.?

Thanks in advance.

Manish
[964 byte] By [Manish Gupta] at [2007-11-9 14:55:21]
# 1 Re: Help in XSL
Manish,

Using MSXML3, try

<xsl:stylesheet name="Test2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method = "html"/>
<xsl:template match="/mydata">
<table>
<xsl:apply-templates select="question-id"/>
</table>
</xsl:template>
<xsl:template match="question-id">
<tr>
<xsl:for-each select="id">
<td><xsl:value-of select="."/></td>
<td><xsl:value-of
select="//questionire/question[qid=current()]/desc"/></td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>

Greg Longtin

Manish Gupta <manish_kumar_73@hotmail.com> wrote in message
news:391aa139$1@news.dev-archive.com...
>
> Hi All,
>
> I have the following XML...
>
> <mydata>
> <question-id>
> <id>1</id>
> <id>4</id>
> <id>2</id>
> </question-id>
> <questionire>
> <question>
> <qid>1</qid>
> <desc>one</desc>
> </question>
> <question>
> <qid>2</qid>
> <desc>Two</desc>
> </question>
> <question>
> <qid>3</qid>
> <desc>Three</desc>
> </question>
> <question>
> <qid>4</qid>
> <desc>Four</desc>
> </question>
> </questionire>
> </mydata>
>
> Now, I was to fetch desc for each id the question-id and want to
put
> in a table. ie for above XML, I want
> output like
>
> 1 One
> 4 Four
> 2 Two
>
> Can any one provide the corresponding XSl.?
>
> Thanks in advance.
>
> Manish
Greg Longtin at 2007-11-11 23:33:57 >