xsl-list
[Top] [All Lists]

RE: XSLT real time use of XML to XML Transformation (Updated AGAIN)

2003-06-11 08:48:49
I've narrowed down the problem in my ASP to this:

source.transformNodeToObject XSLDoc,newSource

by putting a debugging line of:

response.write newSource.xml
response.end

in the asp file I find that newSource isn't being generated. Everything works 
fine up until that point. (files involved follow)

ENTIRE ASP:
<%
'load the data
set source = server.createObject("Msxml2.DOMDocument")
source.async = false
dataFile = Server.mappath("convertxml.xml")
source.load dataFile

'load stylesheet
set XSLDoc = server.createObject("Msxml2.DOMDocument")
XSLDoc.async = false
stylesheetfile=server.mappath("convertxml_2.xsl")
XSLDoc.load stylesheetfile

'Response.Write "<B>everthing after this line is the first transformation 
<BR></B>"
'response.write source.transformNode(XSLDoc)
'Response.Write "<B>everthing before this line is the first transformation 
<BR></B>"


'maker do
set newSource = server.createObject("Msxml2.DOMDocument")
newSource.async = False
newSource.validateOnParse = True

'Response.Write source.xml
'Response.end

source.transformNodeToObject XSLDoc,newSource

Response.Write newSource.xml
Response.end

Response.Write "<B>everthing after this line is the second 
transformation</B><BR>"
response.write newSource.transformNode(XSLDoc)
Response.Write "<B>everthing before this line is the second 
transformation</B><BR>"

%>

ENTIRE XSLT:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:output indent="yes"/>

<xsl:key name="data-by-agent" match="CLIENTDATA" 
use="generate-id(preceding-sibling::USER[1])"/>

<xsl:template match="/">
<DOCUMENT>
<xsl:apply-templates select="//USER" />
</DOCUMENT>
<xsl:for-each select="//AGENT/AGENTNAME">
If you see <xsl:value-of select="."/> tell him this is the new tree.<BR/>
</xsl:for-each>

<xsl:for-each select="//USER">
If you see <xsl:value-of select="."/> tell him this is the old tree.<BR/>
</xsl:for-each>

</xsl:template>

<xsl:template match="CLIENTDATA"/>

<xsl:template match="USER">
   <AGENT>
     <xsl:variable name="thisagentdata"
       select="key('data-by-agent', generate-id())"/>
     <AGENTNAME><xsl:value-of select="."/></AGENTNAME>
     <AGENTID>
       <xsl:value-of select="$thisagentdata[1]"/>
     </AGENTID>
     <AGENTAGE>
       <xsl:value-of select="$thisagentdata[2]"/>
     </AGENTAGE>
     <AGENTSTATUS>
       <xsl:value-of select="$thisagentdata[3]"/>
     </AGENTSTATUS>
   </AGENT>
</xsl:template>

</xsl:stylesheet>

ENTIRE XML:
<?xml version="1.0"?>
<DOCUMENT>

<USER>Agent Smith</USER>
<CLIENTDATA>Asmith</CLIENTDATA>
<CLIENTDATA>33</CLIENTDATA>
<CLIENTDATA>Agent</CLIENTDATA>

<USER>Agent Clyde</USER>
<CLIENTDATA>Aclyde</CLIENTDATA>
<CLIENTDATA>35</CLIENTDATA>
<CLIENTDATA>Agent in Training</CLIENTDATA>

</DOCUMENT>

-Heath

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • RE: XSLT real time use of XML to XML Transformation (Updated AGAIN), HEATH ALLISON <=