364,085 Members | 5185 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

XSLT extension function fails when not running under aspnet_wp.

Jay Allard
P: n/a
Jay Allard
Hello

I posted this in the vb.net group on the 2/25/2004, but didn't get any
response. Here's attempt 2. Does anyone know of a more appropriate
place to post this?

One new piece of information: It fails on any method that it happens
to hit first. I juggled the methods a bit, and it just doesn't matter.
As soon as the XslTransform hits an extension function, it fails with
an invalid argument exception.

Thank you for your help.

----
REPOST FOLLOWS:

Greetings

I have an object that I use with an XSLT. I add the object to the XSLT
using addExtensionObject on the XsltArgumentList.

I built a test aspx to test it. It works great. Then I tried using it
via NUnit, and it always fails. (I've tried starting NUnit within the
project, and also just running it direct. Also, I think the fact that
it's NUnit is inconsequential... I'm guessing that this would probably
happen with any program trying to run it.)

-- Exceptions ---
Outer Exception: System.Xml.Xsl.XsltException: Function
'xsltgenerator:RegularExpressionTest()' has failed.

Inner Exception: System.ArgumentException: Object type cannot be
converted to target type.

I don't understand why it can be converted to the proper target type
when instantiated from an aspx, but not from NUnit.

-- RegularExpressionTest method --
Public Function RegularExpressionTest(ByVal nodes As
System.Xml.XPath.XPathNodeIterator, ByVal sExpression As String) As
String
Return "crap"
nodes.MoveNext()
Return nodes.Current.Value + "[validator:RegExMatch('" +
sExpression + "', .)=0]"
End Function

The "return crap" is a test. It didn't help.



Any ideas? Could it be security related, and if so, what do I need to
know? I didn't have any luck searching MSDN for it.

Thank you.




--- Partial Test Code ---
docData is my source System.Xml.XmlDocument.
GetRulesXSLT() returns a System.Xml.Xsl.XslTransform()

Dim xtRuleXSLT As XslTransform
Dim docResponseXML as New XmlDocument()

xtRuleXSLT = GetRuleXSLT()

Dim args As New XsltArgumentList()
args.AddExtensionObject("urn:validator", New XMLValidator())
docResponseXML.Load(xtRuleXSLT.Transform(New XPathDocument(New
XmlNodeReader(docData)), args))

--- Full Exception ---
System.Xml.Xsl.XsltException: Function
'xsltgenerator:RegularExpressionTest()' has failed. --->
System.ArgumentException: Object type cannot be converted to target
type.
at System.Reflection.RuntimeMethodInfo.InternalInvoke (Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean
verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke (Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[]
parameters)
at System.Xml.Xsl.FuncExtension.Invoke(XsltContext xsltContext,
Object[] args, XPathNavigator docContext)
at System.Xml.XPath.XsltFunction.InvokeFunction(XPath Navigator qy)
--- End of inner exception stack trace ---
at System.Xml.XPath.XsltFunction.InvokeFunction(XPath Navigator qy)
at System.Xml.XPath.XsltFunction.getValue(XPathNaviga tor qy,
XPathNodeIterator iterator)
at System.Xml.XPath.StringFunctions.toString(XPathNav igator
qyContext, XPathNodeIterator iterator)
at System.Xml.XPath.StringFunctions.getValue(XPathNav igator qy,
XPathNodeIterator iterator)
at System.Xml.XPath.StringFunctions.Concat(XPathNavig ator qy,
XPathNodeIterator iterator)
at System.Xml.XPath.StringFunctions.getValue(XPathNav igator qy,
XPathNodeIterator iterator)
at System.Xml.XPath.XPathNavigator.Evaluate(XPathExpr ession expr,
XPathNodeIterator context)
at System.Xml.Xsl.Processor.ValueOf(ActionFrame context, Int32 key)
at System.Xml.Xsl.ValueOfAction.Execute(Processor processor,
ActionFrame frame)
at System.Xml.Xsl.ActionFrame.Execute(Processor processor)
at System.Xml.Xsl.Processor.Execute()
at System.Xml.Xsl.ReaderOutput.Read()
at System.Xml.XPath.XPathDocument.ReadChildNodes(XPat hContainer
parent, String parentBaseUri, XmlReader reader, PositionInfo
positionInfo)
at System.Xml.XPath.XPathDocument.ReadChildNodes(XPat hContainer
parent, String parentBaseUri, XmlReader reader, PositionInfo
positionInfo)
at System.Xml.XPath.XPathDocument.ReadChildNodes(XPat hContainer
parent, String parentBaseUri, XmlReader reader, PositionInfo
positionInfo)
at System.Xml.XPath.XPathDocument.ReadChildNodes(XPat hContainer
parent, String parentBaseUri, XmlReader reader, PositionInfo
positionInfo)
at System.Xml.XPath.XPathDocument.ReadChildNodes(XPat hContainer
parent, String parentBaseUri, XmlReader reader, PositionInfo
positionInfo)
at System.Xml.XPath.XPathDocument.Load(XmlReader reader)
at System.Xml.XPath.XPathDocument..ctor(XmlReader reader, XmlSpace
space)
at System.Xml.Xsl.XslTransform.Load(XmlReader stylesheet,
XmlResolver resolver)
at System.Xml.Xsl.XslTransform.Load(XmlReader stylesheet)
at Lydian.Framework.Validator.Validator.BuildRuleXSLT () in
C:\Development\VB Components\MiniComp\Validator\Validator.vb:line 142
Nov 22 '05 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Help answer this question



Didn't find the answer to your .NET Framework question?

You can also browse similar questions: .NET Framework