|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi All,
I'm a newbie, trying to display an ADO generated XML file, through an XSL. Here's the XML (I edited out some parts to shorten it): <?xml-stylesheet type="text/xsl" href="noa.xsl"?> <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'> <s:Schema id='RowsetSchema'> <s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'> <s:AttributeType name='passenger_id' rs:number='1'> . . . </s:Schema> <rs:data> <z:row passenger_id='1633' firstname='RICHARD ROGER WALKER' lastname='TALBOT' Nationality='UK British Dependent Territories Citizen' expiry_date='2008-10-09T00:00:00'/> <z:row passenger_id='1634' firstname='RICHARD ROGER WALKER' lastname='TALBOT' Nationality='UK British Dependent Territories Citizen' expiry_date='2008-10-09T00:00:00'/> </rs:data> </xml> I'm trying to define the nodes under rs:data in the XSL, in the "for each" statement. Here's my XSL: <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"> <html> <body> <h2>Passengers</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="left">ID</th> <th align="left">Last name</th> <th align="left">First name</th> <th align="left">Nationality</th> <th align="left">Expiration</th> </tr> <xsl:for-each select="xml/rs:data/z:row"> <tr> <td><xsl:value-of select="@passenger_id"/></td> <td><xsl:value-of select="@lastname"/></td> <td><xsl:value-of select="@firstname"/></td> <td><xsl:value-of select="@Nationality"/></td> <td><xsl:value-of select="@expiry_date"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template></xsl:stylesheet> The XSL does not recognize the rs: and z: namespaces, so I get an error. However, when I write simply xml/data/row - without namespace prefixes, the rows are not "picked up" by the ZPath and not displayed (forgive my terms - don't know the lingo). I'd appreciate ideas, Thanks! |
|
#2
|
|||
|
|||
|
Hi Noa. I played around with your code (I'd never worked with ADO-generated XML before), and I think I figured out what you're trying to do.
Just FYI, I found this site: Top XML, that helped me discover the solution to your problem. Look at the code below and let me know if this is what you were trying to accomplish. noa.xml Code:
<?xml-stylesheet type="text/xsl" href="noa.xsl"?>
<rs:data xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset"
xmlns:z="#RowsetSchema" >
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30' />
<s:AttributeType name='passenger_id' rs:number='1' />
</s:Schema>
<z:row passenger_id='1633' firstname='RICHARD ROGER WALKER' lastname='TALBOT' Nationality='UK British Dependent Territories Citizen'
expiry_date='2008-10-09T00:00:00'/>
<z:row passenger_id='1634' firstname='RICHARD ROGER WALKER' lastname='TALBOT' Nationality='UK British Dependent Territories Citizen'
expiry_date='2008-10-09T00:00:00'/>
</rs:data>
noa.xsl Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:html="http://www.w3.org/tr/rec-html40" result-ns="">
<xsl:template match="/">
<html>
<body>
<h2>Passengers</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">ID</th>
<th align="left">Last name</th>
<th align="left">First name</th>
<th align="left">Nationality</th>
<th align="left">Expiration</th>
</tr>
<xsl:for-each select="rs:data/z:row">
<tr>
<td><xsl:value-of select="@passenger_id"/></td>
<td><xsl:value-of select="@lastname"/></td>
<td><xsl:value-of select="@firstname"/></td>
<td><xsl:value-of select="@Nationality"/></td>
<td><xsl:value-of select="@expiry_date"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > define XML elemnt in the XSL, when elemnt path is with namespace prefix |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|