Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 xsl parse problem with Schema in xml result set

Author  Topic 

davidsandra
Starting Member

3 Posts

Posted - 2002-02-25 : 03:18:29
I am using SQL2000 and doing http sql query to get xml:
http://localhost/Budget?sql=SELECT+*+FROM+categories+FOR+XML+AUTO,xmldata&root=table


This returns an XML document with a Schema in it of the datatypes.

The problem is that my stylesheets parsed in IE6 cannot seem to read the Schema elements or these dt:type attributes.

This is quite frustrating. What do I need to do to get my xsl stylesheets to see these elements and attributes



Edited by - merkin on 02/25/2002 06:42:42

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-02-25 : 08:20:21
You may not get this to read correctly using XML Auto. Try using the XML EXPLICIT keyword instead, it's the only way to guarantee the output meets your requirements. Books Online describes how EXPLICIT works.

Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-25 : 08:34:59
Sorry about the edit in your post. I was moving it to the proper forum, this isn't a post that belongs in the script library.

Two things about the XML you usually get back from SQL Server

1. It has no <?xml version="1.0"?> tag at the top.
2. It has more than 1 root element. That is, your results will look like this

<category id="1" name="blah" />
<category id="2" name="blah 2" />

You need to modify this XML before you send it to your XSL sheet by adding the XML declaration, then putting a parent element around your results. Something like :

<?xml version="1.0"?>
<categories>
<category id="1" name="blah" />
<category id="2" name="blah 2" />
</categories>

Hope that helps



Damian
Go to Top of Page

davidsandra
Starting Member

3 Posts

Posted - 2002-02-25 : 09:00:51
Preview

This is actually what I get from SQL Server with this query
http://localhost/Budget?sql=SELECT * FROM who FOR XML AUTO,xmldata&root=who


<?xml version="1.0" encoding="utf-8" ?>
- <who>
- <Schema name="Schema1" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
- <ElementType name="who" content="empty" model="closed">
<AttributeType name="id" dt:type="i4" />
<AttributeType name="person" dt:type="string" />
<attribute type="id" />
<attribute type="person" />
</ElementType>
</Schema>
<who xmlns="x-schema:#Schema1" id="1" person="David" />
<who xmlns="x-schema:#Schema1" id="2" person="Sandra" />
<who xmlns="x-schema:#Schema1" id="3" person="Hannah" />
<who xmlns="x-schema:#Schema1" id="4" person="David and Sandra" />
<who xmlns="x-schema:#Schema1" id="5" person="Family" />
</who>
AS you can see I get the <xml> tag and a root tag. <who>. so I have valid xml.

IE6 shows different colors for xmlns and dt: attributes. Are these special no-touch things or do I have to configure something somewhere in my stylesheet?

My xsl stylesheet can't see anything except the root!

Further help would be appreciated


Go to Top of Page
   

- Advertisement -