writing xml to a ModalDialog window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praan
    New Member
    • Aug 2006
    • 1

    #1

    writing xml to a ModalDialog window

    I am trying to display xml content in a modaldialog window using window.showModa lDialog(), but a blank modaldialog window is displayed.

    can anyone help me with this. Any other way present to display xml in modal dialog window and also to dispaly both html and xml content in a single modaldialog.

    Any help would be appreciated.

    Thanks in advance.
    Praan
  • mione
    New Member
    • Aug 2007
    • 4

    #2
    Originally posted by praan
    I am trying to display xml content in a modaldialog window using window.showModa lDialog(), but a blank modaldialog window is displayed.
    I am having the same problem - does anyone have an answer?

    ------------ Example---------------------
    eg01.xml
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="eg01.xsl" ?>
    <catalog>
      <cd>
        <title>Empire Burlesque</title>
        <artist>Bob Dylan</artist>
        <country>USA</country>
        <company>Columbia</company>
        <price>10.90</price>
        <year>1985</year>
      </cd>
    </catalog>
    eg01.xsl
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
      <html>
      <body>
        <h2>My CD Collection</h2>
        <table border="1">
        <tr bgcolor="#9acd32">
          <th align="left">Title</th>
          <th align="left">Artist</th>
        </tr>
        <xsl:for-each select="catalog/cd">
        <tr>
          <td><xsl:value-of select="title"/></td>
          <td><xsl:value-of select="artist"/></td>
        </tr>
        </xsl:for-each>
        </table>
      </body>
      </html>
    </xsl:template>
    </xsl:stylesheet>
    TestModalXML.ht ml
    Code:
    <html>
    <head>
    <TITLE class="title">
    Testing XML via Modal dialog
    </TITLE>
    </head>
    <body>
    <INPUT TYPE="BUTTON" NAME="xxx" VALUE="show modal dialog" onClick="showModalDialog('http://xxx.xxx/eg01.xml',1,'dialogWidth:1024px; dialogHeight:768px; center:yes')">
    </body>
    </html>

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      showModalDialog only works in IE. Try to use a standard window.open instead.

      Comment

      • mione
        New Member
        • Aug 2007
        • 4

        #4
        Originally posted by acoder
        showModalDialog only works in IE. Try to use a standard window.open instead.
        1) I only need it to work in IE
        (users access the intranet site I'm working on via locked down PC's)

        2) I idealy need the XML to be displayed in a modal dialog, as opposed to just displaying it in a new window

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Originally posted by mione
          1) I only need it to work in IE
          (users access the intranet site I'm working on via locked down PC's)

          2) I idealy need the XML to be displayed in a modal dialog, as opposed to just displaying it in a new window
          I can suggest you this link. Let me know if it works.

          Comment

          • mione
            New Member
            • Aug 2007
            • 4

            #6
            Originally posted by acoder
            I can suggest you this link. Let me know if it works.
            A useful link, Thanks :)

            It doesn't solve my problem unfortunately as the url I want to pass as an argument to the showModalDialog returns the XML I'm trying to display thus I can't pass the xml to the ModalDialog as a dialogArgument as their example does.

            It also doesn't explain why
            Code:
            showModalDialog("http://xxx.xxx/eg01.xml")
            doesn't work but
            Code:
            window.open("http://xxx.xxx/eg01.xml")
            does.

            It has given me some ideas for a possible work around though, which I'm going to persue

            Comment

            • mione
              New Member
              • Aug 2007
              • 4

              #7
              Originally posted by acoder
              I can suggest you this link. Let me know if it works.
              The link turned out to be very useful thanks!!!

              1) Based on what I've seen looking at this issue I think that the problem stems from the modal dialog ignoring the mime type and treating the xml as html

              2) The solution I've got working, if not particularly tidily, relies on javascript loading the xml into an html page on load.......

              change the url passeed to the modal dialog in TestModalXML.ht ml
              Code:
              ...showModalDialog('http://xxx.xxx/eg01.html'....
              eg01.html
              Code:
              <html>
              <head>
              
              <XML id="eg01xml">
              <catalog>
                <cd>
                  <title>Empire Burlesque</title>
                  <artist>Bob Dylan</artist>
                  <country>USA</country>
                  <company>Columbia</company>
                  <price>10.90</price>
                  <year>1985</year>
                </cd>
              </catalog>
              </XML>
              
              <XML id="eg01xsl">
              <xsl:stylesheet version="1.0"
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
              
              <xsl:template match="/">
                <html>
                <body>
                  <h2>My CD Collection</h2>
                  <table border="1">
                  <tr bgcolor="#9acd32">
                    <th align="left">Title</th>
                    <th align="left">Artist</th>
                  </tr>
                  <xsl:for-each select="catalog/cd">
                  <tr>
                    <td><xsl:value-of select="title"/></td>
                    <td><xsl:value-of select="artist"/></td>
                  </tr>
                  </xsl:for-each>
                  </table>
                </body>
                </html>
              </xsl:template>
              
              </xsl:stylesheet>
              </XML>
              
              <script type="text/javascript">
               function testLoad() {
              var xmldom = new ActiveXObject("msxml2.DOMDocument");
              xmldom.async = false;
              xmldom.resolveExternals = false;
              xmldom.loadXML(eg01xml.innerHTML);
              var xsldom = new ActiveXObject("msxml2.DOMDocument");
              xsldom.async = false;
              xsldom.resolveExternals = false;
              xsldom.loadXML(eg01xsl.innerHTML);
              var outputdom = new ActiveXObject("msxml2.DOMDocument");
              outputdom.async = false;
              outputdom.resolveExternals = false;
              xmldom.transformNodeToObject(xsldom, outputdom);
              divTarget.innerHTML = outputdom.xml;
               }
              
              </script>
              </head>
              <body onLoad="testLoad()">
              <div id="divTarget"></div>
              </body>
              </html>

              Comment

              Working...