469,572 Members | 1,307 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

XSLT transforms and complex parameter types

I am attempting to pass in an XmlDocument as a parameter to a transform:

from my sample ASPX page:

string BaseDir = "/cameron/Play/ComplexParam/";

XmlDocument XSL = new XmlDocument();
XSL.Load(HttpContext.Current.Server.MapPath(BaseDi r + "xsl.xsl"));

XmlDocument Data = new XmlDocument();
Data.Load( HttpContext.Current.Server.MapPath(BaseDir + "Data.xml") );

XmlDocument Betty = new XmlDocument();
Betty.LoadXml("<betty>Betty text<whooo>" +
"Woo text</whooo><weee/></betty>");

StringWriter Results = new StringWriter();

XslTransform XSLT = new XslTransform();
XSLT.Load(XSL.DocumentElement.CreateNavigator(),
new XmlUrlResolver(),
Assembly.GetCallingAssembly().Evidence);

XsltArgumentList Args = new XsltArgumentList();
Args.AddParam("InXML", "", Betty.DocumentElement);
//Args.AddParam("InXML", "", Betty);
//Args.AddParam("InXML", "", (XmlNode)Betty.DocumentElement);

XSLT.Transform(Data.DocumentElement.CreateNavigato r(),
Args, Results, (XmlResolver)null);

HttpContext.Current.Response.Write("Transform = " +
Results.ToString());

---------------------------------------------

Data.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Data>
<SomeData>Data-here</SomeData>
</Data>

---------------------------------------------

xsl.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace"
exclude-result-prefixes="msxsl user"
version="1.0">

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:param name="InXML"/>

<xsl:template match="/">
got root
<xsl:if test="$InXML">
<p>InXml looks good to me!</p>

<p>whoo count <xsl:value-of select="count($InXML/whooo)"/></p>
<p>weee count <xsl:value-of select="count($InXML/weee)"/></p>
<p>text '<xsl:value-of select="$InXML/text()"/>'</p>
<xsl:for-each select="$InXML/whooo">
<p>have child</p>
</xsl:for-each>
</xsl:if>
</xsl:template>

</xsl:stylesheet>

---------------------------------------------

Output:
got root
InXml looks good to me!
whoo count 0
weee count 0
text ''

---------------------------------------------

I can do this in IE as a client-side transform without issue but not in
C#. Can anyone see what I am doing wrong?

Thanks

-Cam
Nov 16 '05 #1
1 2200
Hi Cameron,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that XSLTransform works incorrectly when the
parameter contains node. If there is any misunderstanding, please feel free
to let me know.

Based on my research, this is a known issue in current .net framework.
Since IE uses MSXML to process xml data, it is working properly. This issue
will be fixed in the next version of .net framework. Currently, I think you
have to use MSXML to process with the xsl.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by rush | last post: by
22 posts views Thread by john bailo | last post: by
10 posts views Thread by bbembi_de | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.