Calling active:xslt from Groovy with IHDSDocument as operand?

Poster Content
nk4um User
Posts: 168
August 28, 2017 15:04

Ok forget this question. The solution was to add :

myRequestToXSLT.setRepresentationClass(org.netkernel.mod.hds.IHDSDocument.class)

This works perfectly :

INKFRequest myRequestToXSLT = context.createRequest("active:xslt");
myRequestToXSLT.addArgument("operator", "res:/resources/scripts/dependencies-adapt.xsl");
myRequestToXSLT.addArgument("operand", "res:/services/policies/"+paramPolicyName+"/modules/"+moduleName+"/dependencies");
myRequestToXSLT.addArgumentByValue("policyname", paramPolicyName);
myRequestToXSLT.addArgumentByValue("modulename", moduleName);
// THIS !
myRequestToXSLT.setRepresentationClass(org.netkernel.mod.hds.IHDSDocument.class);
IHDSDocument myResponseFromXSLT = context.issueRequest(myRequestToXSLT);

Grégoire

Like · Post Reply
nk4um User
Posts: 168
August 28, 2017 14:50

I tried with directly giving the URI of the resource with addArgument, instead of the resource with addArgumentByValue. I can now get a org.w3c.dom.Document :

INKFRequest myRequestToXSLT = context.createRequest("active:xslt");
myRequestToXSLT.addArgument("operator", "res:/resources/scripts/dependencies-adapt.xsl");
// Here I pass the URI and not a IHDSDocument representation
myRequestToXSLT.addArgument("operand", "res:/services/policies/"+paramPolicyName+"/modules/"+moduleName+"/dependencies");
myRequestToXSLT.addArgumentByValue("policyname", paramPolicyName);
myRequestToXSLT.addArgumentByValue("modulename", moduleName);
// Is that needed?
myRequestToXSLT.setRepresentationClass(org.w3c.dom.Document.class);
// What to do with org.w3c.dom.Document?
org.w3c.dom.Document myResponseFromXSLT = context.issueRequest(myRequestToXSLT);

This call doesn't crash, but how can I query the resulting org.w3c.dom.Document? It seems that I'm quite used to using IHDSDocument now... :)

Like · Post Reply
nk4um User
Posts: 168
August 28, 2017 14:19Calling active:xslt from Groovy with IHDSDocument as operand?

Hi,

I'm trying to call active:xslt from a Groovy script. I want to pass as operand a IHDSDocument. Is that possible?

What I'm trying to do, is this :

IHDSDocument myResource = context.source("res:/services/policies/"+paramPolicyName+"/modules/"+moduleName+"/dependencies", IHDSDocument.class);

INKFRequest myRequestToXSLT = context.createRequest("active:xslt");
myRequestToXSLT.addArgument("operator", "res:/resources/scripts/dependencies-adapt.xsl");
myRequestToXSLT.addArgumentByValue("operand", myResource);
myRequestToXSLT.addArgumentByValue("policyname", paramPolicyName);
myRequestToXSLT.addArgumentByValue("modulename", moduleName);
IHDSDocument myResponseFromXSLT = context.issueRequest(myRequestToXSLT);

List<IHDSReader> myReaders = myResponseFromXSLT.getReader().getNodes("/output/link");

The problem comes from the line where I set the "operand" argument. I get a conversion problem :

org.codehaus.groovy.runtime.typehandling.GroovyCastException
Cannot cast object '[#document: null]' with class 'com.sun.org.apache.xerces.internal.dom.DocumentImpl' to class 'org.netkernel.mod.hds.IHDSDocument'

Is this a transreption problem? Isn't IHDSDocument compatible with active:xslt?

Any hint would be welcome!

Thanks!

Grégoire

Like · Post Reply