Subject: RE: [xsl] XSLT real time use of XML to XML Transformation (Updated Querry) From: "HEATH ALLISON" <HEATH.ALLISON@xxxxxxxxxxxxxxx> Date: Wed, 11 Jun 2003 09:55:55 -0500 |
Firstly, Wendell thanks, and it's Heath. Outstanding suggestion, thanks for introducing me to a new concept! It clearly fixes my node-tree problem. I had it pointed out to me on another forum that my following-sibling method would be problematic as the number of Users grew. Your method seems to be a bette solution all around. Now my tree is working perfectly, but I'm still having trouble getting that data to be accessible to my stylesheet. With Wendell's new stylesheet: <?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> and my 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 source.transformNodeToObject XSLDoc,newSource 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>" %> I get this output: <B>everthing after this line is the first transformation <BR></B> <DOCUMENT> <AGENT> <AGENTNAME>Agent Smith</AGENTNAME> <AGENTID>Asmith</AGENTID> <AGENTAGE>33</AGENTAGE> <AGENTSTATUS>Agent</AGENTSTATUS> </AGENT> <AGENT> <AGENTNAME>Agent Clyde</AGENTNAME> <AGENTID>Aclyde</AGENTID> <AGENTAGE>35</AGENTAGE> <AGENTSTATUS>Agent in Training</AGENTSTATUS> </AGENT> </DOCUMENT> If you see Agent Smith tell him this is the old tree.<BR /> If you see Agent Clyde tell him this is the old tree.<BR /> <B>everthing before this line is the first transformation <BR></B> <B>everthing after this line is the second transformation</B><BR> <B>everthing before this line is the second transformation</B><BR> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT real time use of XML, Wendell Piez | Thread | RE: [xsl] Implementing and Hide/Unh, Jarno . Elovirta |
Re: [xsl] node() implementation, David Carlisle | Date | [xsl] contains any child nodes attr, florian |
Month |