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