[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSLT real time use of XML to XML Transformation (

Subject: RE: 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
real time xsl
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.