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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<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"/>
                </xsl:if>
        </xsl:for-each>
</xsl:variable> 
...
...



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,
                   FileAccess.Read);
   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();
   xslDoc.Load(xslPath);
   xslDoc.Transform(doc,null,Response.Output);
        
   //Close Readers
   reader.Close();
   xmlReader.Close();
 }
</script>


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.


Thanks,
Jae

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to