Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Processing Instruction

Processing Instruction

Scheduled Pinned Locked Moved XML / XSL
xmlcsharpdata-structuressecuritydebugging
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnsaxton
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • J johnsaxton

      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

      P Offline
      P Offline
      Phil Hobgen
      wrote on last edited by
      #2

      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

      J 1 Reply Last reply
      0
      • P Phil Hobgen

        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

        J Offline
        J Offline
        johnsaxton
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • J johnsaxton

          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

          J Offline
          J Offline
          johnsaxton
          wrote on last edited by
          #4

          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

          P 1 Reply Last reply
          0
          • J johnsaxton

            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

            P Offline
            P Offline
            Phil Hobgen
            wrote on last edited by
            #5

            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 to Save("SomeDirOnTheServer\\SomeFileName.xml"); Phil Hobgen barbari.co.uk Southampton, UK

            J 1 Reply Last reply
            0
            • P Phil Hobgen

              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 to Save("SomeDirOnTheServer\\SomeFileName.xml"); Phil Hobgen barbari.co.uk Southampton, UK

              J Offline
              J Offline
              johnsaxton
              wrote on last edited by
              #6

              Phil, 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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups