[xquery-talk] External Variable on AltovaXML 2007

Timothy Marc timothymarc at freenet.de
Sun Jun 24 16:26:40 PDT 2007


Hello,
I want to pass an XML-String to the AltovaXML 2007 XQuery engine as 
external variable. Inside of the xquery, i want to iterate over the 
given variable with the for-expression. But, how do i convert the 
external XML-String into a xml-document for processing? In saxon or 
xalan it is possible to pass the external variables as InputSources, but 
how should this be done in AltovaXML? Is there anyone, who had made some 
experiences with AltovaXML? It seems to be quiet easy.

My Code looks like this:

IXQuery q = AltovaXMLFactory.getInstance().getXQueryInstance();
q.addExternalVariable("try", "<root><chil>Ich</chil></root>");
q.setOutputEncoding("UTF-8");
q.setXQueryFileName("d:\\test.xq");
String resultString = q.executeAndGetResultAsString();
if (resultString == null ) {
System.out.println("XQuery error : "
+ q.getLastErrorMessage());
}
else{
System.out.println("Transform contents>>" + resultString );
}

My XQuery like this:
declare variable $try external;
<result>
{
for $a in $try
return
<erg>{$a/root/chil/text()}</erg>
}
</result>

Thx in advance.
Timothy


More information about the talk mailing list