|
|
|
date: Fri, 1 Aug 2008 10:31:01 -0700,
group: microsoft.public.xsl
back
Debug help
I have a transform that works on a large number of files. Every once and a
while I get the following exception thrown:
A first chance exception of type 'System.Xml.Xsl.XslTransformException'
occurred in System.Data.SqlXml.dll
System.Xml.Xsl.XslTransformException: Cannot convert a node-set which
contains zero nodes or more than one node to a single node.
at System.Xml.Xsl.Runtime.XsltConvert.ToNode(IList`1 listItems)
at <xsl:template match="/">(XmlQueryRuntime
{urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator
{urn:schemas-microsoft-com:xslt-debug}current)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter
results)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer,
Boolean closeWriter)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument,
XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument,
XmlResolver dataSources, XsltArgumentList argumentList, Stream results)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input,
XsltArgumentList arguments, Stream results)
Any hints on how I might be able to isolate the input that is causing the
problem and maybe the line(s) in the stylesheet that are involved?
Thank you.
Kevin
date: Fri, 1 Aug 2008 10:31:01 -0700
author: Kevin Burton
RE: Debug help
Through trial and error I think I have narrowed down the problem to the
following:
Not Merchandised Errors - <xsl:value-of
select="count(/Envelope/Message[(MessageID = $MessageTestList/root/list/item)
and
(bsi:MerchandisedProduct($CatalogConnectionString,Relationship/Relation/SKU))])"/>
May assumption is that
Relationship/Relation/SKU
in the context about is passed to my custom XSL function as a single node.
Perhaps that assumption is in error. So now this is a query question. The
format of the XML document looks like:
<Envelope>
<Message>
<MessageId>1234</MessageId>
<Relationship>
<Relation>
<SKU>5678</SKU>
</Relation>
</Relationship>
</Message>
</Envelope>
I want to make sure that the MessageID is in the first list (that is an
XPath expression). Now I want to make sure that each SKU that is a sub set of
the nodes that match the first XPath to be passed to the custom function.
Is that confusing enough?
Kevin
"Kevin Burton" wrote:
> I have a transform that works on a large number of files. Every once and a
> while I get the following exception thrown:
>
> A first chance exception of type 'System.Xml.Xsl.XslTransformException'
> occurred in System.Data.SqlXml.dll
> System.Xml.Xsl.XslTransformException: Cannot convert a node-set which
> contains zero nodes or more than one node to a single node.
> at System.Xml.Xsl.Runtime.XsltConvert.ToNode(IList`1 listItems)
> at <xsl:template match="/">(XmlQueryRuntime
> {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator
> {urn:schemas-microsoft-com:xslt-debug}current)
> at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
> at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
> at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
> XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter
> results)
> at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
> XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer,
> Boolean closeWriter)
> at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument,
> XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
> at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument,
> XmlResolver dataSources, XsltArgumentList argumentList, Stream results)
> at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input,
> XsltArgumentList arguments, Stream results)
>
>
> Any hints on how I might be able to isolate the input that is causing the
> problem and maybe the line(s) in the stylesheet that are involved?
>
> Thank you.
>
> Kevin
>
date: Fri, 1 Aug 2008 11:33:02 -0700
author: Kevin Burton
RE: Debug help
Update.
Again through trial and error I was able to determine that this "wrapper" in
the xsl seems to be the culprit.
public bool MerchandisedProduct(string connectionString, XPathNavigator nav)
{
SqlFunctions mySqlFunctions = new SqlFunctions(connectionString, nav);
return mySqlFunctions.MerchandisedProduct();
}
It seems that if I use this wrapper with an XPathNavigator that points to
more than one node it fails. The reason that I know that it is the wrapper in
the XSL and not my function is that I changed the return so that it always
returned 'false' so the call was not made to my custom code.
Any idea on how I can change the wrapper so that it handles multiple nodes
as return by an XPath statement like:
bsi:MerchandisedProduct($CatalogConnectionString,Relationship/Relation/SKU)
?
Thank you.
Kevin
"Kevin Burton" wrote:
> Through trial and error I think I have narrowed down the problem to the
> following:
>
> Not Merchandised Errors - <xsl:value-of
> select="count(/Envelope/Message[(MessageID = $MessageTestList/root/list/item)
> and
> (bsi:MerchandisedProduct($CatalogConnectionString,Relationship/Relation/SKU))])"/>
>
> May assumption is that
>
> Relationship/Relation/SKU
>
> in the context about is passed to my custom XSL function as a single node.
> Perhaps that assumption is in error. So now this is a query question. The
> format of the XML document looks like:
>
> <Envelope>
> <Message>
> <MessageId>1234</MessageId>
> <Relationship>
> <Relation>
> <SKU>5678</SKU>
> </Relation>
> </Relationship>
> </Message>
> </Envelope>
>
> I want to make sure that the MessageID is in the first list (that is an
> XPath expression). Now I want to make sure that each SKU that is a sub set of
> the nodes that match the first XPath to be passed to the custom function.
>
> Is that confusing enough?
>
> Kevin
> "Kevin Burton" wrote:
>
> > I have a transform that works on a large number of files. Every once and a
> > while I get the following exception thrown:
> >
> > A first chance exception of type 'System.Xml.Xsl.XslTransformException'
> > occurred in System.Data.SqlXml.dll
> > System.Xml.Xsl.XslTransformException: Cannot convert a node-set which
> > contains zero nodes or more than one node to a single node.
> > at System.Xml.Xsl.Runtime.XsltConvert.ToNode(IList`1 listItems)
> > at <xsl:template match="/">(XmlQueryRuntime
> > {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator
> > {urn:schemas-microsoft-com:xslt-debug}current)
> > at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
> > at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
> > at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
> > XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter
> > results)
> > at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
> > XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer,
> > Boolean closeWriter)
> > at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument,
> > XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter results)
> > at System.Xml.Xsl.XmlILCommand.Execute(IXPathNavigable contextDocument,
> > XmlResolver dataSources, XsltArgumentList argumentList, Stream results)
> > at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input,
> > XsltArgumentList arguments, Stream results)
> >
> >
> > Any hints on how I might be able to isolate the input that is causing the
> > problem and maybe the line(s) in the stylesheet that are involved?
> >
> > Thank you.
> >
> > Kevin
> >
date: Fri, 1 Aug 2008 13:49:01 -0700
author: Kevin Burton
|
|