Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write X-path using @id without having DTD

Status
Not open for further replies.

Adityag74

Programmer
Jan 16, 2003
3
US
Hello

I want to get the attributes's value using @ID without using dtd file.I am little confused How to give X-path for the code written in xsl file.

I am really new to XML and present solustion is not producing any result.

Really appreciate an immediate help.

Many thanks

Adi..

here is my xml file
=====================
<?xml version=&quot;1.0&quot; ?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;TestQ.xsl&quot;?>
<results>
<result id=&quot;getCount&quot;>
<row>
<NOS>1872</NOS>
</row>
</result>
<result id=&quot;getDetails&quot;>
<row>
<NAME>ABC</NAME>
<DESC>Coverage </DESC>
<SOURCE>Covered Universe</SOURCE>
<NOS>1378</NOS>
</row>
<row>
<NAME>XYZ</NAME>
<DESC>Internal </DESC>
<SOURCE>Coverage Analyst</SOURCE>
<NOS>1822</NOS>
</row>
</result>
</results>
=========================
.xsl file TestQ.xsl
=============================
<xsl:stylesheet
xmlns:xsl=&quot;<xsl:template match=&quot;results&quot;>

<table>
<tr>
<td align=&quot;center&quot; >NOS</td>
</tr>
<xsl:for-each select='results/result[@id=&quot;getCount&quot;]/row'>
<tr>
<td><xsl:value-of select=&quot;NOS&quot;/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match=&quot;results&quot;>
<table>
<tr>
<td>NAME</td>
<td>DESC</td>
<td>SOURCE</td>
<td>NOS</td>
</tr>
</table>
</xsl:template>
<xsl:template match=&quot;results&quot;>
<table>
<xsl:for-each select='results/result[@id=&quot;getDetails&quot;]/row'>
<tr>
<td><xsl:value-of select=&quot;NAME&quot;/></td>
<td><xsl:value-of select=&quot;DESC&quot;/></td>
<td><xsl:value-of select=&quot;SOURCE&quot;/></td>
<td><xsl:value-of select=&quot;NOS&quot;/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
====================================
 
Should you change:
Code:
<xsl:template match=&quot;results&quot;>
to
Code:
<xsl:template match=&quot;/&quot;>
Otherwise it looks for
Code:
results/results/result[@id=&quot;foo&quot;]/row
Which doesn't exist. Correct me if I'm wrong.

petey
 
Thanks Petey..

It works..Really appreciate ur reply.

Adi...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top