Transform XML via XSL and save as XML

Discussion in 'C#' started by ill_comms, Jan 15, 2007.

  1. #1
    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:eek:utput 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:eek:therwise>
    </xsl:eek:therwise>
    </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>
    ======================================================
     
    ill_comms, Jan 15, 2007 IP