rherguth
asked on
Am I Insane? This XSLT is not finding my elements
I would expect the data "Schema" to show up in the transformed result. Only "xml" does, so the XSLT is not properly identifying the Schema node when parsed. This seems simple yet I cannot figure it out!
Simplified Source XML which is from a SQL Server SELECT FOR XML AUTO, XMLDATA command:
<?xml version="1.0" encoding="UTF-8"?>
<xml xmlns:sql="urn:schemas-mic rosoft-com :xml-sql">
<Schema name="Schema1" xmlns="urn:schemas-microso ft-com:xml -data" xmlns:dt="urn:schemas-micr osoft-com: datatypes" >
<ElementType name="row" content="empty" model="closed">
<AttributeType name="HiddenActivityID" dt:type="i4"/>
<AttributeType name="HiddenAgreementID" dt:type="i4"/>
<AttributeType name="Contract_x0020_Group " dt:type="string"/>
<AttributeType name="Contractor" dt:type="string"/>
<AttributeType name="Project_x0020_Engine er" dt:type="string"/>
<AttributeType name="Project_x0020_Title" dt:type="string"/>
<AttributeType name="Task_x0020_Number" dt:type="string"/>
<AttributeType name="New_x0020_Mod_x0020_ PR" dt:type="string"/>
<AttributeType name="Task_x0020_Name" dt:type="string"/>
<AttributeType name="Actions" dt:type="string"/>
<AttributeType name="Delete_x0020_Task" dt:type="string"/>
<AttributeType name="HiddenFY" dt:type="i4"/>
<AttributeType name="HiddenCETSerial" dt:type="string"/>
<attribute type="HiddenActivityID"/>
<attribute type="HiddenAgreementID"/>
<attribute type="Contract_x0020_Group "/>
<attribute type="Contractor"/>
<attribute type="Project_x0020_Engine er"/>
<attribute type="Project_x0020_Title" />
<attribute type="Task_x0020_Number"/>
<attribute type="New_x0020_Mod_x0020_ PR"/>
<attribute type="Task_x0020_Name"/>
<attribute type="Actions"/>
<attribute type="Delete_x0020_Task"/>
<attribute type="HiddenFY"/>
<attribute type="HiddenCETSerial"/>
</ElementType>
</Schema>
<row xmlns="x-schema:#Schema1" HiddenActivityID="925" HiddenAgreementID="747" Contract_x0020_Group="Sing le Award" Contractor="XYZ" Project_x0020_Engineer="Jo e TestGuy" Project_x0020_Title="Blah, Blah" Task_x0020_Number="ABC123" New_x0020_Mod_x0020_PR="Ne w" Task_x0020_Name="Blah, Blah" Actions="View" Delete_x0020_Task="Delete" HiddenFY="2005" HiddenCETSerial="A1B"/>
<row xmlns="x-schema:#Schema1" HiddenActivityID="924" HiddenAgreementID="745" Contract_x0020_Group="Sing le Award" Contractor="ABC" Project_x0020_Engineer="Jo e TestGuy" Project_x0020_Title="Blah, Blah 2" Task_x0020_Number="ABC567" New_x0020_Mod_x0020_PR="Ne w" Task_x0020_Name="Blah, Blah 2" Actions="View" Delete_x0020_Task="Delete" HiddenFY="2005" HiddenCETSerial="D1C"/>
<row xmlns="x-schema:#Schema1" HiddenActivityID="923" HiddenAgreementID="744" Contract_x0020_Group="Othe r" Project_x0020_Engineer="Jo e TestGuy" Project_x0020_Title="Blah, Blah 3" Task_x0020_Number="ABC789" New_x0020_Mod_x0020_PR="Ne w" Task_x0020_Name="Blah, Blah 3" Actions="View" Delete_x0020_Task="Delete" HiddenFY="2005" HiddenCETSerial="K1D"/>
</xml>
Simplified XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head/>
<body>
<xsl:for-each select="xml">
xml
<xsl:for-each select="Schema">
Schema
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Simplified Source XML which is from a SQL Server SELECT FOR XML AUTO, XMLDATA command:
<?xml version="1.0" encoding="UTF-8"?>
<xml xmlns:sql="urn:schemas-mic
<Schema name="Schema1" xmlns="urn:schemas-microso
<ElementType name="row" content="empty" model="closed">
<AttributeType name="HiddenActivityID" dt:type="i4"/>
<AttributeType name="HiddenAgreementID" dt:type="i4"/>
<AttributeType name="Contract_x0020_Group
<AttributeType name="Contractor" dt:type="string"/>
<AttributeType name="Project_x0020_Engine
<AttributeType name="Project_x0020_Title"
<AttributeType name="Task_x0020_Number" dt:type="string"/>
<AttributeType name="New_x0020_Mod_x0020_
<AttributeType name="Task_x0020_Name" dt:type="string"/>
<AttributeType name="Actions" dt:type="string"/>
<AttributeType name="Delete_x0020_Task" dt:type="string"/>
<AttributeType name="HiddenFY" dt:type="i4"/>
<AttributeType name="HiddenCETSerial" dt:type="string"/>
<attribute type="HiddenActivityID"/>
<attribute type="HiddenAgreementID"/>
<attribute type="Contract_x0020_Group
<attribute type="Contractor"/>
<attribute type="Project_x0020_Engine
<attribute type="Project_x0020_Title"
<attribute type="Task_x0020_Number"/>
<attribute type="New_x0020_Mod_x0020_
<attribute type="Task_x0020_Name"/>
<attribute type="Actions"/>
<attribute type="Delete_x0020_Task"/>
<attribute type="HiddenFY"/>
<attribute type="HiddenCETSerial"/>
</ElementType>
</Schema>
<row xmlns="x-schema:#Schema1" HiddenActivityID="925" HiddenAgreementID="747" Contract_x0020_Group="Sing
<row xmlns="x-schema:#Schema1" HiddenActivityID="924" HiddenAgreementID="745" Contract_x0020_Group="Sing
<row xmlns="x-schema:#Schema1" HiddenActivityID="923" HiddenAgreementID="744" Contract_x0020_Group="Othe
</xml>
Simplified XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head/>
<body>
<xsl:for-each select="xml">
xml
<xsl:for-each select="Schema">
Schema
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! I figured that it was a namespace problem because that was all that was left, but I didn't really understand how they're used. I had your site bookmarked already, so I probably had already found something useful there before.
I am creating an XSLT from one that I had created to gen tables from a saved XML ADO Stream, which formats the XML differently than MS SQL does. I've found that the ADO XML Stream method of doings things is very slow compared to grabbing the ADO stream result directly from a MS SQL FOR XML AUTO, XMLDATA or EXPLICIT command. So I'm nearly done now. It was just this aspect that was holding me up for awhile.
I am creating an XSLT from one that I had created to gen tables from a saved XML ADO Stream, which formats the XML differently than MS SQL does. I've found that the ADO XML Stream method of doings things is very slow compared to grabbing the ADO stream result directly from a MS SQL FOR XML AUTO, XMLDATA or EXPLICIT command. So I'm nearly done now. It was just this aspect that was holding me up for awhile.
ASKER
Mike,
Please see my new q:
https://www.experts-exchange.com/questions/21217701/SQL-FOR-XML-AUTO-XMLDATA-varies-Schema-name.html
:)
Please see my new q:
https://www.experts-exchange.com/questions/21217701/SQL-FOR-XML-AUTO-XMLDATA-varies-Schema-name.html
:)
ASKER
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
xml
</body>
</html>