Transform XML via XSL and save as XML

  • 14 years ago

    Hi All,

    I'm attempting to save the xsl processors output back into XML, however when it gets to the save method it bombs out saying:

    Object required: 'xmlNewDoc'.

    Also I have dumped the contents of the output in the html and it works fine and the output I wanted is correct. For whatever reason it doesn't want to save. And its not a permissions settings as I have full rights.

    Code is as follows, if anyone can help I'd be most greatful!

    =============ASP====================================
    Set xslDoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
    xslDoc.async = False
    xslDoc.setProperty "SelectionLanguage", "XPath"
    xslDoc.load( Server.MapPath("styles/xsl/rep_service_action.xsl") )



    Set xmlTemplate = Server.CreateObject("Msxml2.XSLTemplate.3.0")
    xmlTemplate.stylesheet = xslDoc

    Set myProc = xmlTemplate.createProcessor()
    myProc.input = xmlGroupDoc
     
    myProc.transform()


    Set xmlNewDoc = Server.CreateObject("Msxml2.DOMDocument.3.0")
    xmlNewDoc.async = False
    xmlNewDoc.validateOnParse = False
    xmlNewDoc.preserveWhiteSpace = True
    xmlNewDoc.resolveExternals = False
    xmlNewDoc = myProc.output
    xmlNewDoc.save("C:\AMS_Final\MAINTENANCE\temp4.xml")
    =======================================================






    =============XSL=======================================
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:variable name="theStylesheet" select="document('')" />
    <xsl:output method="xml" version="4.0" encoding="utf-8"/>



    <xsl:template match="SERVICE_REQUESTS">
     <xsl:apply-templates select="REQUEST_LIST"/>
    </xsl:template>

    <xsl:template match="REQUEST_LIST">
     <xsl:choose>
      <xsl:when test="count(row) > 0 ">
       <chart title='My Chart' legend='right'>
        <pie radius="1500" squash="1.5" thickness="20" labels="percent" />
        <style>
         <title font="Georgia" size="20" color="#FF9900" bold="true" />
         <label font="Arial" size="12" color="#000000" bold="false" />
         <legend rowodd="#EEEEEE" even="#DDDDDD" border="#000000" />
        </style>
        <values sort="descending">
         <node value="30" label="widget 1" color="#FF0000" />
         <node value="20" label="widget 2" color="#00FF00" />
         <node value="60" label="widget 3" color="#0000FF" />
        </values>
       </chart>
      </xsl:when>
      <xsl:otherwise>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>
    ======================================================





















Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov