Processing Instruction
-
This is the case of the disappearing processing instruction. I am writing a web-service. I am adding an XML processing instruction as shown in the code snipet below. (Sorry about the line wraps) xmlDoc.LoadXml(""); xmlDoc.InsertBefore(xmlDoc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"wsinfo.xsl\""), xmlDoc.DocumentElement); I can view the item in the debugger and see the PI in the InnerXML. I can still see the PI in the XmlDocument right before the webservice ends. Yet when the XML is displayed in IE, no PI... what gives? IF I write the PI after the root, it remains in the returned XML however, IE seems to ignore it. The XSL is never executed and the result that I see in IE is the XML tree. Can someone please point out the error of my ways? I am sure it is a stupid error at this point... I just can't see it. Thanks! John M. Saxton, Jr. Microsoft Certified Application Developer for .NET CompTIA Security+ Certified
-
This is the case of the disappearing processing instruction. I am writing a web-service. I am adding an XML processing instruction as shown in the code snipet below. (Sorry about the line wraps) xmlDoc.LoadXml(""); xmlDoc.InsertBefore(xmlDoc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"wsinfo.xsl\""), xmlDoc.DocumentElement); I can view the item in the debugger and see the PI in the InnerXML. I can still see the PI in the XmlDocument right before the webservice ends. Yet when the XML is displayed in IE, no PI... what gives? IF I write the PI after the root, it remains in the returned XML however, IE seems to ignore it. The XSL is never executed and the result that I see in IE is the XML tree. Can someone please point out the error of my ways? I am sure it is a stupid error at this point... I just can't see it. Thanks! John M. Saxton, Jr. Microsoft Certified Application Developer for .NET CompTIA Security+ Certified
Hi, I've never seen the PI anywhere but before the root element. So that should be correct. Are you sure that "wsinfo.xsl" is located relative to the url that returns the xml? When you say the PI is not displayed in IE, do you mean in the browser or in the "View Source" notepad? The xml shouldn't be seen in the browser, you should see the result of the transformed xml. Cheers Phil Hobgen barbari.co.uk Southampton, UK
-
Hi, I've never seen the PI anywhere but before the root element. So that should be correct. Are you sure that "wsinfo.xsl" is located relative to the url that returns the xml? When you say the PI is not displayed in IE, do you mean in the browser or in the "View Source" notepad? The xml shouldn't be seen in the browser, you should see the result of the transformed xml. Cheers Phil Hobgen barbari.co.uk Southampton, UK
Phil, Thanks for your reply. As far as I know PIs may be anywhere in the XML, but I do want this one at the top as shown below: I have verified that wsinfo.xsl is located in code and bin directories for the url that returns the XML. I know I don't need both, but for now I am trying everything. When I say that the PI is not displayed, I mean that it is not present in the XML. Here is a snipet of the returned XML. - I guess the exact point of the problem is that the PI is missing from the final XML. As a result the XML is not being transformed when it is dsiplayed in the browser. If I save the XML and open it in notepad ... there is no stylesheet PI. Any clues? P.S. The xsl is valid XML and if I manually add the stylesheet PI to the XML, it is properly transformed when displayed in IE. John M. Saxton, Jr. Microsoft Certified Application Developer for .NET CompTIA Security+ Certified
-
Phil, Thanks for your reply. As far as I know PIs may be anywhere in the XML, but I do want this one at the top as shown below: I have verified that wsinfo.xsl is located in code and bin directories for the url that returns the XML. I know I don't need both, but for now I am trying everything. When I say that the PI is not displayed, I mean that it is not present in the XML. Here is a snipet of the returned XML. - I guess the exact point of the problem is that the PI is missing from the final XML. As a result the XML is not being transformed when it is dsiplayed in the browser. If I save the XML and open it in notepad ... there is no stylesheet PI. Any clues? P.S. The xsl is valid XML and if I manually add the stylesheet PI to the XML, it is properly transformed when displayed in IE. John M. Saxton, Jr. Microsoft Certified Application Developer for .NET CompTIA Security+ Certified
Phil, Thanks for your reply. The code didn't show up in the first post. As far as I know PIs may be anywhere in the XML, but I do want this one at the top as shown below: ... I have verified that wsinfo.xsl is located in code and bin directories for the url that returns the XML. I know I don't need both, but for now I am trying everything. When I say that the PI is not displayed, I mean that it is not present in the XML. Here is a snipet of the returned XML. ... I guess the exact point of the problem is that the PI is missing from the final XML. As a result the XML is not being transformed when it is dsiplayed in the browser. If I save the XML and open it in notepad ... there is no stylesheet PI. Any clues? P.S. The xsl is valid XML and if I manually add the stylesheet PI to the XML, it is properly transformed when displayed in IE. John M. Saxton, Jr. Microsoft Certified Application Developer for .NET CompTIA Security+ Certified
-
Phil, Thanks for your reply. The code didn't show up in the first post. As far as I know PIs may be anywhere in the XML, but I do want this one at the top as shown below: ... I have verified that wsinfo.xsl is located in code and bin directories for the url that returns the XML. I know I don't need both, but for now I am trying everything. When I say that the PI is not displayed, I mean that it is not present in the XML. Here is a snipet of the returned XML. ... I guess the exact point of the problem is that the PI is missing from the final XML. As a result the XML is not being transformed when it is dsiplayed in the browser. If I save the XML and open it in notepad ... there is no stylesheet PI. Any clues? P.S. The xsl is valid XML and if I manually add the stylesheet PI to the XML, it is properly transformed when displayed in IE. John M. Saxton, Jr. Microsoft Certified Application Developer for .NET CompTIA Security+ Certified
Hi, I'm not sure how you are transferring the xml to the browser. To work out if the problem is with the
XmlDocument
or with the transfer of the xml you could try a call toSave("SomeDirOnTheServer\\SomeFileName.xml");
Phil Hobgen barbari.co.uk Southampton, UK -
Hi, I'm not sure how you are transferring the xml to the browser. To work out if the problem is with the
XmlDocument
or with the transfer of the xml you could try a call toSave("SomeDirOnTheServer\\SomeFileName.xml");
Phil Hobgen barbari.co.uk Southampton, UKPhil, Added the Save. XML that gets saved has both PIs, which is as expected. Now I just need to get the ASP.NET app that is calling this webservice to display it properly. Its not optimal. I would rather have this webservice return a XmlDocument, but I can live with it returning a filename for now. Thanks again. John M. Saxton, Jr. Microsoft Certified Application Developer for .NET CompTIA Security+ Certified