SQL XML vs. XSL

  • I am trying to use XSL to transform XML generated by a query (using FOR XML AUTO). If I tell the query to generate the a schema (using XMLDATA), the xsl fails to transform the data. If I do not have the query generate the schema, the xsl transforms the data as designed.

    Unfortunately, the middle tier I am working against only supports SQLXML that returns the inline schema.

    Has anyone else seen this issue and what, if anything, can I do to resolve this problem.

    Steve Osoba

    Developer

  • Could you post some sample xml, and the xsl?

    Tim C.

    //Will write code for food


    Tim C //Will code for food

  • Using the MSXML 4 parser with the following XML and XSL gives me nothing.

    XML:

    <?xml version="1.0"?>
    
    <blah>
    <Schema name="Schema1" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
    <ElementType name="TestView" content="empty" model="closed">
    <AttributeType name="RecordId" dt:type="i4"/>
    <AttributeType name="RecordDate" dt:type="dateTime"/>
    <AttributeType name="Product" dt:type="string"/>
    <attribute type="RecordId"/>
    <attribute type="RecordDate"/>
    <attribute type="Product"/>
    </ElementType>
    </Schema>
    <TestView xmlns="x-schema:#Schema1" RecordId="195" RecordDate="2003-02-23T00:00:00" Product="Widget" />
    <TestView xmlns="x-schema:#Schema1" RecordId="196" RecordDate="2003-02-23T00:00:00" Product="Widget" />
    <TestView xmlns="x-schema:#Schema1" RecordId="197" RecordDate="2003-02-24T00:00:00" Product="Widget" />
    <TestView xmlns="x-schema:#Schema1" RecordId="198" RecordDate="2003-02-24T00:00:00" Product="Widget" />
    <TestView xmlns="x-schema:#Schema1" RecordId="199" RecordDate="2003-02-25T00:00:00" Product="Widget" />
    </blah>

    XSL:

    <?xml version="1.0"?>
    
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <xsl:template match="/">
    <html>
    <head><title>Testing</title></head>
    <body>
    <table>
    <xsl:for-each select="/blah/TestView">
    <tr><td><xsl:value-of select="position()"/></td></tr>
    </xsl:for-each>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    HTML Output:

    <html>
    
    <head>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-16">
    <title>Testing</title></head>
    <body>
    <table>
    </table>
    </body>
    </html>

    Thanks,

    Steve O.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply