XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 14th, 2004, 02:08 AM
Noa Noa is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 Noa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy define XML elemnt in the XSL, when elemnt path is with namespace prefix

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!

Reply With Quote
  #2  
Old January 29th, 2004, 04:04 PM
tsprings tsprings is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: Seattle, WA
Posts: 55 tsprings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 5
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>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > define XML elemnt in the XSL, when elemnt path is with namespace prefix


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT