Subject: [xsl] Validate using MSXML From: Michael Nielsen <xsl-list@xxxxxxxxxx> Date: Wed, 29 Apr 2009 16:11:06 +0200 |
Sorry if this list is not for a specific engine, but I simply can't find any help to my problem. I'm using Microsoft XML to render my XSL and I have a project consisting of the following files: sample_data.xml feeData.xsd fees_language.xml fees_language.xsd fees.xslt The sample_data.xml references the feeData.xsd and is valid, fees_language references fees_language.xsd and is also valid. The XSLT itself is able to transform the XML in sample_data.xml to HTML, and uses the fees_language.xml as a variable in this way: <xsl:variable name="Language_Id" select="Fee_Root/Fees/@Language_Id"/> <xsl:variable name="Language" select="document('fees_language.xml')/Languages/Language[@Language_Id=$Language_Id]"/> This selects the correct language from my fees_language, and puts it into a variable. When I open my sample_data.xml in Firefox or Internet Explorer, it renders correctly. And when I debug my XSLT in Stylus Studio, it als renders correctly. However, I would like to check if the XML is valid when parsing in my ASP solution and here is how i do it: (Code simplified, I have removed a lot of error checking) -- Setup Objects Set objXMLDOM = Server.CreateObject("MSXML2.DOMDocument.4.0") Set objFreeDOM = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0") Set objXSLTemplate = Server.CreateObject("MSXML2.XSLTemplate.4.0") Set objXSDCache = Server.CreateObject("Msxml2.XMLSchemaCache.4.0") -- Add XSD to Cache, and then to the objXMLDOM Dim XSDName : XSDName = Request.servervariables("APPL_PHYSICAL_PATH").item & "feeData.xsd" objXSDCache.Add "", XSDName set objXMLDOM.schemas = objXSDCache -- Load XML, xml_string is XML generated from the database objXMLDom.loadXML(xml_string) -- Load XSL into a free threaded DOM objFreeDOM.async = False objFreeDOM.resolveExternals = False (I have also tested with True) objFreeDOM.validateOnParse = False objFreeDOM.load(filename) -- Attach XSL to Template objXSLTemplate.stylesheet = objFreeDOM -- Create the processor Dim processor set processor = objXSLTemplate.createProcessor -- Transform processor.transform -- And then output result = processor.output (Code done) When i run this code i get an error: Error while parsing "file:///F:/CVS/fees_language.xml". The element 'Languages' is used but not declared in the DTD/Schema. It says that the Languages element is not part of the feeData.xsd - Thats correct, its part of its own XSD named fees_language.xsd. Is there a way of getting around this error? I would prefer to have separate XSD's for each of my XML files, but I also would like to know if the XML fed to the XSL is bad. And putting it all into one XSD is also something I'd like to avoid. If I ommit the line: set objXMLDOM.schemas = objXSDCache It works like a charm (but is not validating the XML) Files can be zipped and made available upon request. Best regards, Michael Nielsen
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Placing an element in a v, G. Ken Holman | Thread | Re: [xsl] Validate using MSXML, Martin Honnen |
RE: [xsl] GROUPING AND KEYS, Cleyton Jordan | Date | Re: [xsl] Validate using MSXML, Martin Honnen |
Month |