[Mono-list] XSLT transform problems...

Jae Stutzman jaebird at coolaccess.net
Sat Jul 9 14:46:05 EDT 2005

I'm doing some XSLT transforms in ASP.NET and I'm seeing a difference in
behavior from MS.NET. It seems to have to do with multiple xml documents
using the document() function.

<?xml version="1.0"?>
<xsl:transform version="1.0"

<xsl:output method="html"/>

<xsl:variable name="currentUser" select="root/user"/>

<xsl:variable name="usersDoc" select="document('users.xml')"/>

<xsl:variable name="currentThemePark">
	<xsl:for-each select="$usersDoc/userSettings/user">
		<xsl:if test="id=currentUser">
			<xsl:value-of select="favPark"/>

My aspx file looks like this...
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<script language="C#" runat="server">
   public void Page_Load(Object sender, EventArgs E) {		
   string xmlPath = Server.MapPath("main.xml");
   string xslPath = Server.MapPath("main.xsl"); 
   FileStream fs = new FileStream(xmlPath,FileMode.Open,
   StreamReader reader = new StreamReader(fs,Encoding.UTF8);
   XmlTextReader xmlReader = new XmlTextReader(reader);
   //Instantiate the XPathDocument Class
   XPathDocument doc = new XPathDocument(xmlReader);

   //Instantiate the XslTransform Class
   XslTransform xslDoc = new XslTransform();
   //Close Readers

When I include the currentThemePark variable I lose both variables when
I try to get the value-of them. Under MS ASP.NET this works fine.

This seems like a bug? Could be an XPath problem dealing with multiple
documents. Is there another way to accomplish this? I need to have
multiple XML documents.


More information about the Mono-list mailing list