fritz_the_blank
asked on
Different XML Formats?
I have a standard XML file as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="DataContent.xsl"?>
<DataContent>
<person>
<name>Sam the Clam</name>
<detail>Sea Dweller</detail>
<age>39</age>
</person>
<person>
<name>Fred the Fish</name>
<detail>Sea Dweller</detail>
<age>18</age>
</person>
</DataContent>
and if I use the following XSL file:
<?xml version="1.0" encoding="ISO-8859-1"?><xs l:styleshe et version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">
<html>
<body>
<h2>Data Content Display</h2>
<table border="0" cellspacing="2">
<tr bgcolor="gray">
<th align="left" width="100">Name</th>
<th align="left" width="150">Detail</th>
<th align="left" width="50">Age</th>
</tr>
<xsl:for-each select="DataContent/person ">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="detail"/></td>
<td><xsl:value-of select="age"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:style sheet>
I can create an ASP page as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
sourceFile = Server.MapPath("DataConten t.xml")
styleFile = Server.MapPath("DataConten t.xsl")
set source = Server.CreateObject("Micro soft.XMLDO M")
source.async = false
source.load(sourceFile)
set style = Server.CreateObject("Micro soft.XMLDO M")
style.async = false
style.load(styleFile)
Response.Write source.transformNode(style )
%>
However, if I use ADO to create my XML:
objRS.save strPath adPersistXML
then the XML looks different like this example from the Northwind database:
<xml xmlns:s='uuid:BDC6E3F0-6DA 3-11d1-A2A 3-00AA00C1 4882'
xmlns:dt='uuid:C2F41010-65 B3-11d1-A2 9F-00AA00C 14882'
xmlns:rs='urn:schemas-micr osoft-com: rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:updatable='true'>
<s:AttributeType name='CompanyName' rs:number='1' rs:nullable='true' rs:maydefer='true' rs:write='true' rs:basetable='Customers'
rs:basecolumn='CompanyName '>
<s:datatype dt:type='string' dt:maxLength='40'/>
</s:AttributeType>
<s:AttributeType name='ContactName' rs:number='2' rs:nullable='true' rs:maydefer='true' rs:write='true' rs:basetable='Customers'
rs:basecolumn='ContactName '>
<s:datatype dt:type='string' dt:maxLength='30'/>
</s:AttributeType>
<s:AttributeType name='Phone' rs:number='3' rs:nullable='true' rs:maydefer='true' rs:write='true' rs:basetable='Customers'
rs:basecolumn='Phone'>
<s:datatype dt:type='string' dt:maxLength='24'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row CompanyName='Alfreds Futterkiste' ContactName='Maria Anders' Phone='030-0074321'/>
<z:row CompanyName='Ana Trujillo Emparedados y helados' ContactName='Ana Trujillo' Phone='(5) 555-4729'/>
<z:row CompanyName='Antonio Moreno TaquerÃa' ContactName='Antonio Moreno' Phone='(5) 555-3932'/>
<z:row CompanyName='Around the Horn' ContactName='Thomas Hardy' Phone='(171) 555-7788'/>
<z:row CompanyName='Berglunds snabbköp' ContactName='Christina Berglund' Phone='0921-12 34 65'/>
</rs:data>
</xml>
So now for the question: how do I work with this second XML format to accomplish the same thing? For your answer, please keep in mind that I am very new to XML/XSL and will need a little hand holding.
Thanks,
Fritz the Blank
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="DataContent.xsl"?>
<DataContent>
<person>
<name>Sam the Clam</name>
<detail>Sea Dweller</detail>
<age>39</age>
</person>
<person>
<name>Fred the Fish</name>
<detail>Sea Dweller</detail>
<age>18</age>
</person>
</DataContent>
and if I use the following XSL file:
<?xml version="1.0" encoding="ISO-8859-1"?><xs
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template
<html>
<body>
<h2>Data Content Display</h2>
<table border="0" cellspacing="2">
<tr bgcolor="gray">
<th align="left" width="100">Name</th>
<th align="left" width="150">Detail</th>
<th align="left" width="50">Age</th>
</tr>
<xsl:for-each select="DataContent/person
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="detail"/></td>
<td><xsl:value-of select="age"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:style
I can create an ASP page as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
sourceFile = Server.MapPath("DataConten
styleFile = Server.MapPath("DataConten
set source = Server.CreateObject("Micro
source.async = false
source.load(sourceFile)
set style = Server.CreateObject("Micro
style.async = false
style.load(styleFile)
Response.Write source.transformNode(style
%>
However, if I use ADO to create my XML:
objRS.save strPath adPersistXML
then the XML looks different like this example from the Northwind database:
<xml xmlns:s='uuid:BDC6E3F0-6DA
xmlns:dt='uuid:C2F41010-65
xmlns:rs='urn:schemas-micr
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:updatable='true'>
<s:AttributeType name='CompanyName' rs:number='1' rs:nullable='true' rs:maydefer='true' rs:write='true' rs:basetable='Customers'
rs:basecolumn='CompanyName
<s:datatype dt:type='string' dt:maxLength='40'/>
</s:AttributeType>
<s:AttributeType name='ContactName' rs:number='2' rs:nullable='true' rs:maydefer='true' rs:write='true' rs:basetable='Customers'
rs:basecolumn='ContactName
<s:datatype dt:type='string' dt:maxLength='30'/>
</s:AttributeType>
<s:AttributeType name='Phone' rs:number='3' rs:nullable='true' rs:maydefer='true' rs:write='true' rs:basetable='Customers'
rs:basecolumn='Phone'>
<s:datatype dt:type='string' dt:maxLength='24'/>
</s:AttributeType>
<s:extends type='rs:rowbase'/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row CompanyName='Alfreds Futterkiste' ContactName='Maria Anders' Phone='030-0074321'/>
<z:row CompanyName='Ana Trujillo Emparedados y helados' ContactName='Ana Trujillo' Phone='(5) 555-4729'/>
<z:row CompanyName='Antonio Moreno TaquerÃa' ContactName='Antonio Moreno' Phone='(5) 555-3932'/>
<z:row CompanyName='Around the Horn' ContactName='Thomas Hardy' Phone='(171) 555-7788'/>
<z:row CompanyName='Berglunds snabbköp' ContactName='Christina Berglund' Phone='0921-12 34 65'/>
</rs:data>
</xml>
So now for the question: how do I work with this second XML format to accomplish the same thing? For your answer, please keep in mind that I am very new to XML/XSL and will need a little hand holding.
Thanks,
Fritz the Blank
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you to both!!!
I am going to study this carefully to see what I can learn.
Once I have a working example, I find that following tutorials and the like is a whole lot easier.
FtB
I am going to study this carefully to see what I can learn.
Once I have a working example, I find that following tutorials and the like is a whole lot easier.
FtB
ASKER
I tried modifying my xsl file to match the field names, but it always returned an empty table--no errors but no data...
FtB