[Mono-list] XSLT transform problems...Solved.

Jae Stutzman jaebird at coolaccess.net
Sat Jul 9 19:13:37 EDT 2005


Actually it looks like user error! I was declaring DTDs in some of the
XML documents, the DTDs were missing...

MS.NET ignored the errors for the variable stuff...and then wouldn't
return anything from them in the body of the stylesheet.

Mono worked consistently in both sections.

Cheers,

Jae

On Sun, 2005-07-10 at 04:30 +0900, Atsushi Eno wrote:
> Hello,
> 
> Jae Stutzman wrote:
> > 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.
> 
> If main.xml, main.xsl and users.xml (referenced in the stylesheet)
> are really in the same directory, then it sounds like a bug (on
> url resolution). It is XSLT problem (document() function is one
> from XSLT spec). In such case please file it to bugzilla and I'll
> fix it later.
> 
> For workaround you can pass the full path filename as a variable
> (for document() argument) in XsltArgumentList argument for
> XslTransform.Transform().
> 
> Atsushi Eno
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 



More information about the Mono-list mailing list