Schema and Stylesheet
-
Hi Friends, I am using XML as database in my application and for datadefinition in xml file I create .xsd file (schema file) and set the target schema property to the .xsd file. Till that every thing is working fine. NOw I am trying to export the xml file to msexcel worksheet. and for that I have created an .xslt file which formats data of xml file. The problem is that the stylesheets works properly only if the xml file is not bind to the schema file. If I bind the xml file to the schema file it give nothing as output and without schema data validation is not possible. Is there any way to bind schema and stylesheet together? if any one is having this idea plz let me know. Thank u all in advance. Thanks and regards, Chetan Ranpariya.
-
Hi Friends, I am using XML as database in my application and for datadefinition in xml file I create .xsd file (schema file) and set the target schema property to the .xsd file. Till that every thing is working fine. NOw I am trying to export the xml file to msexcel worksheet. and for that I have created an .xslt file which formats data of xml file. The problem is that the stylesheets works properly only if the xml file is not bind to the schema file. If I bind the xml file to the schema file it give nothing as output and without schema data validation is not possible. Is there any way to bind schema and stylesheet together? if any one is having this idea plz let me know. Thank u all in advance. Thanks and regards, Chetan Ranpariya.
Since your XML file uses a Schema, it has a default namespace. I believe you have to have your XSLT recognize the namespace of the nodes it is transforming.
-
Since your XML file uses a Schema, it has a default namespace. I believe you have to have your XSLT recognize the namespace of the nodes it is transforming.
Hi George, Thank you for the reply. The way u suggest it right but I dont know how to do that? The xslt file that I had made is like this. <?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"></xsl:output> <xsl:template match="/"> <xsl:param name="CompCode"/> <html> <body> <h2>Activities</h2> <table border="1" cellpadding ="2"> <tr bgcolor="#9acd32"> <th>Sequence Number</th> <th>Details</th> </tr> <xsl:for-each select="CompsAndRels/RelationshipMaster[ProjectCode=$CompCode]"> <xsl:sort select="SequenceNumber" data-type="number"></xsl:sort> <xsl:variable name="recursive_result"> <xsl:value-of select="RelCode"></xsl:value-of></xsl:variable> <tr> <td colspan="2"> <b> <xsl:value-of select="SequenceNumber"></xsl:value-of>. <xsl:value-of select="RelDescription"></xsl:value-of></b> </td> </tr> <xsl:for-each select="../ActivityMaster[ActivityRelCode=$recursive_result]"> <xsl:sort select="ActivitySeqNo" data-type="number"></xsl:sort> <tr> <td bgcolor="#ffffcc"> <xsl:value-of select="ActivitySeqNo"></xsl:value-of> </td> <td bgcolor="#ffffcc"> <xsl:value-of select="ActivityDetail"></xsl:value-of> </td> </tr> </xsl:for-each> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> and My XML file is as following. <CompsAndRels xmlns="http://tempuri.org/ComponentsAndRelationships.xsd"> <ComponentMaster> <ComponentCode>35476350</ComponentCode> <ComponentName>BRUSH</ComponentName> <ComponentDescription>fa;sl asd.fas dlf;as f.sdf aslj</ComponentDescription> <ComponentParent>0</ComponentParent> <ComponentCost>500</ComponentCost> <CompnentWorth>500</CompnentWorth> <UserID>mrchetanrana</UserID> <ProjectCode>5847</ProjectCode> <ComponentColor>ffffff</ComponentColor> &
-
Hi George, Thank you for the reply. The way u suggest it right but I dont know how to do that? The xslt file that I had made is like this. <?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"></xsl:output> <xsl:template match="/"> <xsl:param name="CompCode"/> <html> <body> <h2>Activities</h2> <table border="1" cellpadding ="2"> <tr bgcolor="#9acd32"> <th>Sequence Number</th> <th>Details</th> </tr> <xsl:for-each select="CompsAndRels/RelationshipMaster[ProjectCode=$CompCode]"> <xsl:sort select="SequenceNumber" data-type="number"></xsl:sort> <xsl:variable name="recursive_result"> <xsl:value-of select="RelCode"></xsl:value-of></xsl:variable> <tr> <td colspan="2"> <b> <xsl:value-of select="SequenceNumber"></xsl:value-of>. <xsl:value-of select="RelDescription"></xsl:value-of></b> </td> </tr> <xsl:for-each select="../ActivityMaster[ActivityRelCode=$recursive_result]"> <xsl:sort select="ActivitySeqNo" data-type="number"></xsl:sort> <tr> <td bgcolor="#ffffcc"> <xsl:value-of select="ActivitySeqNo"></xsl:value-of> </td> <td bgcolor="#ffffcc"> <xsl:value-of select="ActivityDetail"></xsl:value-of> </td> </tr> </xsl:for-each> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> and My XML file is as following. <CompsAndRels xmlns="http://tempuri.org/ComponentsAndRelationships.xsd"> <ComponentMaster> <ComponentCode>35476350</ComponentCode> <ComponentName>BRUSH</ComponentName> <ComponentDescription>fa;sl asd.fas dlf;as f.sdf aslj</ComponentDescription> <ComponentParent>0</ComponentParent> <ComponentCost>500</ComponentCost> <CompnentWorth>500</CompnentWorth> <UserID>mrchetanrana</UserID> <ProjectCode>5847</ProjectCode> <ComponentColor>ffffff</ComponentColor> &
... Any references to your document (CompsAndRels) must be made through the "car" namespace (car:CompsAndRels). -- modified at 16:33 Tuesday 28th March, 2006