|
|
|
date: Tue, 26 Aug 2008 13:14:01 -0700,
group: microsoft.public.xsl
back
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
|
|