Skip to content

Commit

Permalink
premiers TU Ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Marchand committed Nov 30, 2015
1 parent ae18784 commit e7c4085
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/fr/efl/saxon/basex/BaseXQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public ExtensionFunctionCall makeCallExpression() {

@Override
public Sequence call(XPathContext xpc, Sequence[] sqncs) throws XPathException {
System.out.println("sqncs[0]: "+sqncs[0].head().getClass().getName());
System.out.println("sqncs[1]: "+sqncs[1].head().getClass().getName());
// System.out.println("sqncs[0]: "+sqncs[0].head().getClass().getName());
// System.out.println("sqncs[1]: "+sqncs[1].head().getClass().getName());
String xquery = ((StringValue)sqncs[0].head()).getStringValue();
TinyElementImpl basexNode = ((TinyElementImpl)sqncs[1].head());
String server=null, port=null, user=null, password=null;
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/fr/efl/saxon/basex/BaseXQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.sf.saxon.s9api.XsltCompiler;
import net.sf.saxon.s9api.XsltTransformer;
import net.sf.saxon.trans.XPathException;
import org.apache.commons.io.output.NullOutputStream;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -72,7 +73,7 @@ public static void stopServer() throws Exception {
*/
@Test
public void testGetFunctionQName() {
System.out.println("getFunctionQName");
// System.out.println("getFunctionQName");
BaseXQuery instance = new BaseXQuery();
StructuredQName expResult = new StructuredQName("efl-ext", "fr:efl:saxon:extensions", "basex-query");
StructuredQName result = instance.getFunctionQName();
Expand All @@ -96,17 +97,18 @@ public void testMakeCallExpression() {
DocumentBuilder builder = proc.newDocumentBuilder();
XdmNode docConnect = builder.build(new StreamSource(new ByteArrayInputStream(CONNECT_STRING.getBytes("UTF-8"))));
XdmNode connect = (XdmNode)docConnect.axisIterator(Axis.DESCENDANT_OR_SELF, new QName("basex")).next();
System.err.println("connect is "+connect.getClass().getName());
System.err.println("connect is "+connect.getNodeName());
System.err.println("connect is "+connect.getNodeKind());
// System.err.println("connect is "+connect.getClass().getName());
// System.err.println("connect is "+connect.getNodeName());
// System.err.println("connect is "+connect.getNodeKind());

xp.setVariable(var, connect);
xp.setContextItem(docConnect);
XdmValue result = xp.evaluate();
SequenceIterator it = result.getUnderlyingValue().iterate();
Item item = it.next();
int count = 1;
while(item!=null) {
System.out.println(item.getClass().getName()+" -> "+item.getStringValue());
assertEquals(Integer.toString(count++),item.getStringValue());
item=it.next();
}
it.close();
Expand All @@ -121,7 +123,6 @@ public void testMakeCallExpression() {
*/
@Test
public void testGetArgumentTypes() {
System.out.println("getArgumentTypes");
BaseXQuery instance = new BaseXQuery();
SequenceType[] expResult = new SequenceType[] {SequenceType.SINGLE_STRING, SequenceType.SINGLE_ELEMENT_NODE};
SequenceType[] result = instance.getArgumentTypes();
Expand All @@ -135,7 +136,6 @@ public void testGetArgumentTypes() {
*/
@Test
public void testGetResultType() {
System.out.println("getResultType");
SequenceType[] sts = null;
BaseXQuery instance = new BaseXQuery();
SequenceType expResult = SequenceType.ANY_SEQUENCE;
Expand All @@ -155,8 +155,8 @@ public void testXsl() {
fail("Impossible de charger la XSL");
}
XsltTransformer t = compiler.compile(new StreamSource(is)).load();
t.setDestination(proc.newSerializer(System.err));
t.setInitialContextNode(proc.newDocumentBuilder().build(new StreamSource(this.getClass().getClassLoader().getResourceAsStream("fr/efl/saxon/basex/test1.xsl"))));
t.setDestination(proc.newSerializer(new NullOutputStream()));
t.setInitialContextNode(proc.newDocumentBuilder().build(new StreamSource(new FileInputStream(new File(new File(System.getProperty("user.dir")),"src/test/resources/test1.xsl")))));
t.transform();
} catch (SaxonApiException | FileNotFoundException ex) {
ex.printStackTrace(System.err);
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/test1.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
version="2.0">
<xsl:output method="xml"/>

<xsl:variable name="connect" as="elment()"><basex><server>localhost</server><port>1984</port><user>admin</user><password>admin</password></basex></xsl:variable>
<xsl:variable name="connect" as="element()"><basex><server>localhost</server><port>1984</port><user>admin</user><password>admin</password></basex></xsl:variable>

<xsl:template match="/">
<result>
Expand Down

0 comments on commit e7c4085

Please sign in to comment.