Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Tue, 26 Aug 2008 13:14:01 -0700,    group: microsoft.public.xsl        back       


Different XPath testing behavior when using xslCompiledTransform(t   
When I use xslCompiledTransform() or xslCompiledTransform(false) I find that 
the XPath queries in my select query attributes do not recognize any 
attributes inthe xml document.  But when I enable debugging 
-xslCompiledTransform(true)- everything works as it should.
for example:
<Root>
  <test attr1="avalue" />
  <test attr1="anothervalue" />
</Root>
doing a 
<xsl:for-each select="/Root/test">
    <xsl:sort select="@attr1" />
</xsl:for-each >
will sort using xslCompiledTransform(true) but not 
xslCompiledTransform(false).  The problem is the select="@attr1" returns 
attribute values in debugging mode but not in run mode.  I am using Visual 
Studio 2005 with .NET Framework 2.0 SP1 for an IIS web solution on Windows XP 
SP2.
date: Tue, 26 Aug 2008 13:14:01 -0700   author:   wejiv

Re: Different XPath testing behavior when using xslCompiledTransform(t   
"wejiv"  wrote in message
news:6264DCF8-898C-43FB-AFAE-A4FFA0A67F99@microsoft.com...
> When I use xslCompiledTransform() or xslCompiledTransform(false) I find
that
> the XPath queries in my select query attributes do not recognize any
> attributes inthe xml document.  But when I enable debugging
> -xslCompiledTransform(true)- everything works as it should.
> for example:
> <Root>
>   <test attr1="avalue" />
>   <test attr1="anothervalue" />
> </Root>
> doing a
> <xsl:for-each select="/Root/test">
>     <xsl:sort select="@attr1" />
> </xsl:for-each >
> will sort using xslCompiledTransform(true) but not
> xslCompiledTransform(false).  The problem is the select="@attr1" returns
> attribute values in debugging mode but not in run mode.  I am using Visual
> Studio 2005 with .NET Framework 2.0 SP1 for an IIS web solution on Windows
XP
> SP2.

Is this really your code?  If so I suspect you are seeing the result of
optimisation.  Looking at the code you've posted the for-each doesn't do
anything therefore when compiled without debug the optimised code just
doesn't do the for-each at all.


-- 
Anthony Jones - MVP ASP/ASP.NET
date: Tue, 26 Aug 2008 22:23:59 +0100   author:   Anthony Jones

Re: Different XPath testing behavior when using xslCompiledTransfo   
No, I did paraphrase per se.  It is really more like:

<xsl:variable nme="aname">
  <xsl:for-each select="/Root/test">
      <xsl:sort select="@attr1" />
      <xsl:copy-of select="." />
  </xsl:for-each >
</xsl:variable>

In this case it would just build the collection in the same order as the 
original children set:

<test attr1="avalue" />
<test attr1="anothervalue" />


"Anthony Jones" wrote:

> "wejiv"  wrote in message
> news:6264DCF8-898C-43FB-AFAE-A4FFA0A67F99@microsoft.com...
> > When I use xslCompiledTransform() or xslCompiledTransform(false) I find
> that
> > the XPath queries in my select query attributes do not recognize any
> > attributes inthe xml document.  But when I enable debugging
> > -xslCompiledTransform(true)- everything works as it should.
> > for example:
> > <Root>
> >   <test attr1="avalue" />
> >   <test attr1="anothervalue" />
> > </Root>
> > doing a
> > <xsl:for-each select="/Root/test">
> >     <xsl:sort select="@attr1" />
> > </xsl:for-each >
> > will sort using xslCompiledTransform(true) but not
> > xslCompiledTransform(false).  The problem is the select="@attr1" returns
> > attribute values in debugging mode but not in run mode.  I am using Visual
> > Studio 2005 with .NET Framework 2.0 SP1 for an IIS web solution on Windows
> XP
> > SP2.
> 
> Is this really your code?  If so I suspect you are seeing the result of
> optimisation.  Looking at the code you've posted the for-each doesn't do
> anything therefore when compiled without debug the optimised code just
> doesn't do the for-each at all.
> 
> 
> -- 
> Anthony Jones - MVP ASP/ASP.NET
> 
> 
>
date: Wed, 27 Aug 2008 05:36:00 -0700   author:   wejiv

Re: Different XPath testing behavior when using xslCompiledTransfo   
wejiv wrote:
> No, I did paraphrase per se.  It is really more like:
> 
> <xsl:variable nme="aname">
>   <xsl:for-each select="/Root/test">
>       <xsl:sort select="@attr1" />
>       <xsl:copy-of select="." />
>   </xsl:for-each >
> </xsl:variable>
> 
> In this case it would just build the collection in the same order as the 
> original children set:
> 
> <test attr1="avalue" />
> <test attr1="anothervalue" />

Here is a complete sample document, based on your posted sample:

<Root>
   <test attr1="avalue" />
   <test attr1="anothervalue" />
</Root>

Here is a complete sample stylesheet, based on your posted samples:

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml" indent="yes"/>
   <xsl:template match="/">
     <result>
       <xsl:variable name="aname">
         <xsl:for-each select="/Root/test">
           <xsl:sort select="@attr1" />
           <xsl:copy-of select="." />
         </xsl:for-each>
       </xsl:variable>
       <xsl:copy-of select="$aname"/>
     </result>
   </xsl:template>
</xsl:stylesheet>

Here is sample C# code executing a transformation:

             XslCompiledTransform xsltProc = new XslCompiledTransform(true);
             xsltProc.Load(@"..\..\XSLTFile1.xslt");
             xsltProc.Transform(@"..\..\XMLFile1.xml", null, Console.Out);
             Console.WriteLine();

Output in the console with Visual Studio 2005 is

<?xml version="1.0" encoding="ibm850"?>
<result>
   <test attr1="anothervalue" />
   <test attr1="avalue" />
</result>

which looks fine to me.

When I change the C# code to

             XslCompiledTransform xsltProc = new 
XslCompiledTransform(false);
             xsltProc.Load(@"..\..\XSLTFile1.xslt");
             xsltProc.Transform(@"..\..\XMLFile1.xml", null, Console.Out);
             Console.WriteLine();

the output is

<?xml version="1.0" encoding="ibm850"?>
<result>
   <test attr1="anothervalue" />
   <test attr1="avalue" />
</result>

which is also fine.

If you think you have hit a bug then you can also report that on 
http://connect.microsoft.com/

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Wed, 27 Aug 2008 15:01:50 +0200   author:   Martin Honnen

Re: Different XPath testing behavior when using xslCompiledTransfo   
ok.  I figured out more of what was happening.  Your code worked for me as 
well.  What I was doing that I hadn't mentioned was that I had created a 
subclass of xmlReader and was passing that in to XPathDocument and using that 
XPathDocument instance in my xslCompiledTransform transform() method.  So 
something about my reader causes the xslCompiledTransform to behave 
differently depending on whether I am debugging the xsl or not.
    I declared all of abstract methods and I don't get any errors building 
my new xmlReader class.  I get no exceptions when using it to parse my xml 
document and, of course, while debugging I can see my attributes.  But when I 
try to use it with or without visual studio and XslCompiledTransform(false) I 
get no values returned for my attributes.
    When I step through the xsl file:
=================================================
1            xmlReader = New XmlData2010SASDataReader(FilePath)
2            
3            doc = New XPathDocument(xmlReader)
4            XMLNavigator = doc.CreateNavigator
5            xslDoc = New XslCompiledTransform(false)
6            xslDoc.Load(xslPath)
7            xslDoc.Transform(doc, New XsltArgumentList(), Response.Output)
==================================================
In Visual Studio line 3 does all of the activity of reading the xmlReader 
and going through it's methods and getting correct values for elements and 
attributes but I get no activity for reading xmlReader in line 7.
    I am using a SortedDictionary object to store my attributes while on an 
element.  The element and attributes are encapsulated in another state object 
that the xmlReader subclass (XmlData2010SASDataReader) uses in all of the 
overridden abstract methods of XMLReader superclass (GetAttribute(string), 
MoveToFirstAttribute(), etc).
    My getAttribute(int) transports all my key/value pairs to an array so 
that I can present the relevant attribute.
    Maybe the SortDictionary object is not safe for this kind of setting.
    Any ideas or thoughts?  How I can trace back to my problem?

"Martin Honnen" wrote:

> wejiv wrote:
> > No, I did paraphrase per se.  It is really more like:
> > 
> > <xsl:variable nme="aname">
> >   <xsl:for-each select="/Root/test">
> >       <xsl:sort select="@attr1" />
> >       <xsl:copy-of select="." />
> >   </xsl:for-each >
> > </xsl:variable>
> > 
> > In this case it would just build the collection in the same order as the 
> > original children set:
> > 
> > <test attr1="avalue" />
> > <test attr1="anothervalue" />
> 
> Here is a complete sample document, based on your posted sample:
> 
> <Root>
>    <test attr1="avalue" />
>    <test attr1="anothervalue" />
> </Root>
> 
> Here is a complete sample stylesheet, based on your posted samples:
> 
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>    <xsl:output method="xml" indent="yes"/>
>    <xsl:template match="/">
>      <result>
>        <xsl:variable name="aname">
>          <xsl:for-each select="/Root/test">
>            <xsl:sort select="@attr1" />
>            <xsl:copy-of select="." />
>          </xsl:for-each>
>        </xsl:variable>
>        <xsl:copy-of select="$aname"/>
>      </result>
>    </xsl:template>
> </xsl:stylesheet>
> 
> Here is sample C# code executing a transformation:
> 
>              XslCompiledTransform xsltProc = new XslCompiledTransform(true);
>              xsltProc.Load(@"..\..\XSLTFile1.xslt");
>              xsltProc.Transform(@"..\..\XMLFile1.xml", null, Console.Out);
>              Console.WriteLine();
> 
> Output in the console with Visual Studio 2005 is
> 
> <?xml version="1.0" encoding="ibm850"?>
> <result>
>    <test attr1="anothervalue" />
>    <test attr1="avalue" />
> </result>
> 
> which looks fine to me.
> 
> When I change the C# code to
> 
>              XslCompiledTransform xsltProc = new 
> XslCompiledTransform(false);
>              xsltProc.Load(@"..\..\XSLTFile1.xslt");
>              xsltProc.Transform(@"..\..\XMLFile1.xml", null, Console.Out);
>              Console.WriteLine();
> 
> the output is
> 
> <?xml version="1.0" encoding="ibm850"?>
> <result>
>    <test attr1="anothervalue" />
>    <test attr1="avalue" />
> </result>
> 
> which is also fine.
> 
> If you think you have hit a bug then you can also report that on 
> http://connect.microsoft.com/
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
>
date: Thu, 28 Aug 2008 13:21:02 -0700   author:   wejiv

Re: Different XPath testing behavior when using xslCompiledTransfo   
I have recompiled my custom XMLReader class twice:
1) I put a lock on the sortedDictionary object in the various methods that 
utilizes it.
2) I put a lock on the custom class that XmlData2010SASDataReader uses for 
element information within XmlData2010SASDataReader's accessor methods.
Neither changed the behavior.

"wejiv" wrote:

> ok.  I figured out more of what was happening.  Your code worked for me as 
> well.  What I was doing that I hadn't mentioned was that I had created a 
> subclass of xmlReader and was passing that in to XPathDocument and using that 
> XPathDocument instance in my xslCompiledTransform transform() method.  So 
> something about my reader causes the xslCompiledTransform to behave 
> differently depending on whether I am debugging the xsl or not.
>     I declared all of abstract methods and I don't get any errors building 
> my new xmlReader class.  I get no exceptions when using it to parse my xml 
> document and, of course, while debugging I can see my attributes.  But when I 
> try to use it with or without visual studio and XslCompiledTransform(false) I 
> get no values returned for my attributes.
>     When I step through the xsl file:
> =================================================
> 1            xmlReader = New XmlData2010SASDataReader(FilePath)
> 2            
> 3            doc = New XPathDocument(xmlReader)
> 4            XMLNavigator = doc.CreateNavigator
> 5            xslDoc = New XslCompiledTransform(false)
> 6            xslDoc.Load(xslPath)
> 7            xslDoc.Transform(doc, New XsltArgumentList(), Response.Output)
> ==================================================
> In Visual Studio line 3 does all of the activity of reading the xmlReader 
> and going through it's methods and getting correct values for elements and 
> attributes but I get no activity for reading xmlReader in line 7.
>     I am using a SortedDictionary object to store my attributes while on an 
> element.  The element and attributes are encapsulated in another state object 
> that the xmlReader subclass (XmlData2010SASDataReader) uses in all of the 
> overridden abstract methods of XMLReader superclass (GetAttribute(string), 
> MoveToFirstAttribute(), etc).
>     My getAttribute(int) transports all my key/value pairs to an array so 
> that I can present the relevant attribute.
>     Maybe the SortDictionary object is not safe for this kind of setting.
>     Any ideas or thoughts?  How I can trace back to my problem?
> 
> "Martin Honnen" wrote:
> 
> > wejiv wrote:
> > > No, I did paraphrase per se.  It is really more like:
> > > 
> > > <xsl:variable nme="aname">
> > >   <xsl:for-each select="/Root/test">
> > >       <xsl:sort select="@attr1" />
> > >       <xsl:copy-of select="." />
> > >   </xsl:for-each >
> > > </xsl:variable>
> > > 
> > > In this case it would just build the collection in the same order as the 
> > > original children set:
> > > 
> > > <test attr1="avalue" />
> > > <test attr1="anothervalue" />
> > 
> > Here is a complete sample document, based on your posted sample:
> > 
> > <Root>
> >    <test attr1="avalue" />
> >    <test attr1="anothervalue" />
> > </Root>
> > 
> > Here is a complete sample stylesheet, based on your posted samples:
> > 
> > <xsl:stylesheet version="1.0" 
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> >    <xsl:output method="xml" indent="yes"/>
> >    <xsl:template match="/">
> >      <result>
> >        <xsl:variable name="aname">
> >          <xsl:for-each select="/Root/test">
> >            <xsl:sort select="@attr1" />
> >            <xsl:copy-of select="." />
> >          </xsl:for-each>
> >        </xsl:variable>
> >        <xsl:copy-of select="$aname"/>
> >      </result>
> >    </xsl:template>
> > </xsl:stylesheet>
> > 
> > Here is sample C# code executing a transformation:
> > 
> >              XslCompiledTransform xsltProc = new XslCompiledTransform(true);
> >              xsltProc.Load(@"..\..\XSLTFile1.xslt");
> >              xsltProc.Transform(@"..\..\XMLFile1.xml", null, Console.Out);
> >              Console.WriteLine();
> > 
> > Output in the console with Visual Studio 2005 is
> > 
> > <?xml version="1.0" encoding="ibm850"?>
> > <result>
> >    <test attr1="anothervalue" />
> >    <test attr1="avalue" />
> > </result>
> > 
> > which looks fine to me.
> > 
> > When I change the C# code to
> > 
> >              XslCompiledTransform xsltProc = new 
> > XslCompiledTransform(false);
> >              xsltProc.Load(@"..\..\XSLTFile1.xslt");
> >              xsltProc.Transform(@"..\..\XMLFile1.xml", null, Console.Out);
> >              Console.WriteLine();
> > 
> > the output is
> > 
> > <?xml version="1.0" encoding="ibm850"?>
> > <result>
> >    <test attr1="anothervalue" />
> >    <test attr1="avalue" />
> > </result>
> > 
> > which is also fine.
> > 
> > If you think you have hit a bug then you can also report that on 
> > http://connect.microsoft.com/
> > 
> > -- 
> > 
> > 	Martin Honnen --- MVP XML
> > 	http://JavaScript.FAQTs.com/
> >
date: Fri, 29 Aug 2008 08:13:01 -0700   author:   wejiv

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us