0

i am new in XSLT domain,i have an html file that is rendering content of XML file through XSLT.Now after some dynamic change in XML CAN the XSLT behave according to that dynamic change is XML and the html page render that dynamic content or should there is need to reopen that html file in which that xml is referenced.

My XMl File is like

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="XSL.xsl"?>
<Arithmetic>
    <Function>
        <FunctionName>-</FunctionName>
    </Function>
    <Function>
        <FunctionName>/</FunctionName>
    </Function>
    <Function>
        <FunctionName>*</FunctionName>
    </Function>
    <Function>
        <FunctionName>MOD</FunctionName>
    </Function>
    <Function>
        <FunctionName>^</FunctionName>
    </Function>
   </Arithmetic>

And my XSLT file is

**<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/*">
  <html>
  <body>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Title</th>

    </tr>
    <xsl:for-each select="/*/Function">
    <tr>
      <td><xsl:value-of select="FunctionName"/></td>

    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>** 

My Sample html would be like

<html>
<head>
<SCRIPT LANGUAGE=javascript>

 function createDom(stringXML){
        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); // create a xmlDOM object
         xmlDoc.async="false"
         xmlDoc.loadXML(stringXML);
return xmlDoc;
} 
function onOk()
{
    xmlDom2 = createDom("<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="XSL.xsl"?><Geometric><Function><FunctionName>-</FunctionName></Function><Function><FunctionName>/</FunctionName></Function><Function><FunctionName>*</FunctionName></Function><Function><FunctionName>MOD</FunctionName></Function><Function><FunctionName>^</FunctionName></Function></Geometric>");
    //now how could i give ref of that updated xml in the iframe or how the iframe will render this update xml 
}
</SCRIPT >

</head>
<body >
    <div id = "mainDiv" class = "scrollbar" style = "border:1px inset;height: 186px; overflow: auto;">

        <IFRAME src = "XML.xml" id="IFRAME" style="visibility: visible;" ></IFRAME> 
        <INPUT id=btnOk onclick=onOk() type=button size=35 value=Change XML >

    </div>
</body>
</html>

thanks

zaree
  • 641
  • 2
  • 6
  • 15

3 Answers3

3

You might like to look at Saxon-CE for this kind of application. Saxon-CE runs XSLT 2.0 in the browser, and allows you to write template rules that respond to specific events. If the XML is on the server then of course it won't automatically notice that the server-side XML has changed, but you can arrange to communicate with an application on the server to get notification of such events.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
0

The rendering in the html will depend in the xml and the xslt mark ups. If the changes in the xml is not defined in the xslt then the render will not happen in html.

eliseobeltran
  • 568
  • 3
  • 11
0

If you edit your XML after opening it in your browser, you'll need to run the XSLT transformation process again.

The HTML you see in the browser is the result of a rendering process which is not run dynamically. I guess you can watch your XML for change and rebuild the HTML file, but that's gonna be a command line approach.

Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178