XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
mahesh deshmukhSubject: Output the XslCompiledTransform
Author: mahesh deshmukh
Date: 25 Oct 2006 12:01 PM
Question:- How do I get the results of the XSLCompiledTransform.Transform method into an XML.XMLreader object?



Hi,

I ran into following situation when migrating my framework 1.1 codes to 2.0:

Old situation (.net v1.1):

==========xslt file=============
<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xslt.html#strip">

<xsl:output method="text" version="1.0"

encoding="UTF-8" indent="no"/>

<xsl:variable name="SelectedStateId" />

<xsl:template match="Jurisdictions">

<xsl:param name="iSelectedStateId" select="$SelectedStateId" />

&lt;script type="text/java-script"&gt;

//Array for List items

//Xsl-Param:SelectedStateId: <xsl:value-of select="$iSelectedStateId" />

var tmpCityArr = new Array(3);

tmpCityArr[0] =

<xsl:for-each select="Country[JurisId=50001]">

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />'<xsl:for-each select="State">,

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />'<xsl:if test="JurisId = $SelectedStateId"><xsl:for-each select="City">,

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />')<!-- SELECTED -->

</xsl:for-each></xsl:if>)</xsl:for-each></xsl:for-each>

);

tmpCityArr[1] =

<xsl:for-each select="Country[JurisId=50002]">

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />'<xsl:for-each select="State">,

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />'<xsl:if test="JurisId = $SelectedStateId"><xsl:for-each select="City">,

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />')<!-- SELECTED -->

</xsl:for-each></xsl:if>)</xsl:for-each></xsl:for-each>

);

tmpCityArr[2] =

new Array('International|' <xsl:for-each select="Country[JurisId != 50001 and JurisId != 50002]">,

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />'<xsl:if test="JurisId = $SelectedStateId"><xsl:for-each select="State">,

new Array('<xsl:value-of select="JurisName" />|<xsl:value-of select="JurisId" />')

</xsl:for-each></xsl:if>)</xsl:for-each>

);

&lt;/script&gt;

</xsl:template>

</xsl:stylesheet>

===================================

==============aspx page codebehind========
private XmlReader __prepareXmlData(IXPathNavigable inputXml, string xslTransform, object[] xslParams )

{

//get transform

XslTransform xt = new XslTransform();

xt.Load(Server.MapPath(xslTransform));

XsltArgumentList xslArgs = new XsltArgumentList();

if (null != xslParams)

{

for (int i = 0; i < xslParams.Length; i++)

xslArgs.AddParam((string)xslParams[i], tring.Empty, xslParams[++i]);

}

//transform string

XmlUrlResolver resolver = new XmlUrlResolver();

resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;

XmlReader xr = xt.Transform(inputXml, xslArgs, resolver);

Retrurn(xr);

}


=============================

Facts in the ASP 2.0 world are:
1 Now, new and shiny XslCompiledTransform class doesn't support this feature anymore, transformation output is now only Stream, TextWriter or XmlWriter

2) XslTransform objects (class) is obsolete as well.

Note: for the above method we are Storing the Xslt file in resources is fine. When you need the file the easiest solution is to write the resource to file and use the XslCompiledTransform.Load (String) where String is path of file.

All above code is working fine in .net 1.1 but it’s not working in .net 2.0.



Hope you can help?
Thanks.
best regards
Mahesh



Posttop
Tony LavinioSubject: Output the XslCompiledTransform
Author: Tony Lavinio
Date: 25 Oct 2006 02:36 PM
First, a question for you: How does this relate to using
Stylus Studio? This is a Stylus Studio help forum. You
might be better off using a Microsoft XSLT forum.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.