Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
/http-client-java/dist/
/http-client-saxon/build/
/http-client-saxon/dist/
target
*~

/bin
115 changes: 115 additions & 0 deletions http-client-java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.expath.httpclient</groupId>
<artifactId>expath-httpclient-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<name>EXPath HTTP Client</name>
<description>EXPath HTTP Client</description>
<url>http://expath.org/</url>
<scm>
<url>git@github.com:fgeorges/expath-http-client-java.git</url>
<connection>scm:git@github.com:fgeorges/expath-http-client-java.git</connection>
<developerConnection>scm:git:https://github.com/fgeorges/expath-http-client-java</developerConnection>
</scm>
<developers>
<developer>
<id>fgeorges</id>
<name>Florent Georges</name>
<email>fgeorges@expath.org</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.ccil.cowan.tagsoup</groupId>
<artifactId>tagsoup</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j</artifactId>
<version>0.6.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- override some common Maven defaults to conform to this project's layout -->
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<check>
<lineRate>90</lineRate>
</check>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
116 changes: 116 additions & 0 deletions http-client-saxon/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.expath.httpclient</groupId>
<artifactId>expath-httpclient-saxon</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<name>EXPath HTTP Client</name>
<description>EXPath HTTP Client</description>
<url>http://expath.org/</url>
<scm>
<url>git@github.com:fgeorges/expath-http-client-java.git</url>
<connection>scm:git@github.com:fgeorges/expath-http-client-java.git</connection>
<developerConnection>scm:git:https://github.com/fgeorges/expath-http-client-java</developerConnection>
</scm>
<developers>
<developer>
<id>fgeorges</id>
<name>Florent Georges</name>
<email>fgeorges@expath.org</email>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.expath.httpclient</groupId>
<artifactId>expath-httpclient-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.expath.packaging</groupId>
<artifactId>pkg-saxon</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.5.1-2</version>
<!--<version>9.4.0.7</version>-->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- override some common Maven defaults to conform to this project's layout -->
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<check>
<lineRate>90</lineRate>
</check>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Arrays;
import java.util.Iterator;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.om.Axis;
import net.sf.saxon.om.AxisInfo;
import net.sf.saxon.om.NamePool;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.om.SequenceIterator;
Expand Down Expand Up @@ -77,7 +77,7 @@ public String getAttribute(String local_name)
// get the attribute
NamePool pool = myNode.getNamePool();
NodeTest pred = new NameTest(Type.ATTRIBUTE, "", local_name, pool);
AxisIterator attrs = myNode.iterateAxis(Axis.ATTRIBUTE, pred);
AxisIterator attrs = myNode.iterateAxis(AxisInfo.ATTRIBUTE, pred);
NodeInfo a = (NodeInfo) attrs.next();
// return its string value, or null if there is no such attribute
if ( a == null ) {
Expand All @@ -91,7 +91,7 @@ public String getAttribute(String local_name)
@Override
public Iterable<Attribute> attributes()
{
AxisIterator it = myNode.iterateAxis(Axis.ATTRIBUTE);
AxisIterator it = myNode.iterateAxis(AxisInfo.ATTRIBUTE);
return new AttributeIterable(it);
}

Expand All @@ -101,7 +101,7 @@ public boolean hasNoNsChild()
{
NamePool pool = myNode.getNamePool();
NodeTest no_ns_pred = new NamespaceTest(pool, Type.ELEMENT, "");
return myNode.iterateAxis(Axis.CHILD, no_ns_pred).moveNext();
return myNode.iterateAxis(AxisInfo.CHILD, no_ns_pred).moveNext();
}

@Override
Expand All @@ -117,7 +117,7 @@ public void noOtherNCNameAttribute(String[] names)
}
Arrays.sort(sorted);
String elem_name = myNode.getDisplayName();
AxisIterator it = myNode.iterateAxis(Axis.ATTRIBUTE);
AxisIterator it = myNode.iterateAxis(AxisInfo.ATTRIBUTE);
NodeInfo attr;
while ( (attr = (NodeInfo) it.next()) != null ) {
String attr_name = attr.getDisplayName();
Expand All @@ -140,15 +140,15 @@ else if ( Arrays.binarySearch(sorted, attr.getLocalPart()) < 0 ) {
public Sequence getContent()
throws HttpClientException
{
SequenceIterator it = myNode.iterateAxis(Axis.CHILD);
SequenceIterator it = myNode.iterateAxis(AxisInfo.CHILD);
return new SaxonSequence(it, myCtxt);
}

@Override
public Iterable<Element> children()
throws HttpClientException
{
AxisIterator it = myNode.iterateAxis(Axis.CHILD, NodeKindTest.ELEMENT);
AxisIterator it = myNode.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT);
return new ElemIterable(it);
}

Expand All @@ -158,7 +158,7 @@ public Iterable<Element> children(String ns)
{
NamePool pool = myNode.getNamePool();
NodeTest pred = new NamespaceTest(pool, Type.ELEMENT, ns);
AxisIterator it = myNode.iterateAxis(Axis.CHILD, pred);
AxisIterator it = myNode.iterateAxis(AxisInfo.CHILD, pred);
return new ElemIterable(it);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
import javax.xml.transform.Source;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.om.Item;
import net.sf.saxon.om.Sequence;
import net.sf.saxon.om.SequenceIterator;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.tree.iter.ArrayIterator;
import net.sf.saxon.value.Base64BinaryValue;
import net.sf.saxon.value.SequenceExtent;
import net.sf.saxon.value.StringValue;
import org.expath.httpclient.HttpClientException;
import org.expath.httpclient.HttpResponse;
Expand Down Expand Up @@ -85,6 +87,13 @@ public SequenceIterator newIterator()
return new ArrayIterator(array);
}

public Sequence asSequence()
throws HttpClientException
{
Item[] array = myItems.toArray(new Item[0]);
return new SequenceExtent<Item>(array);
}

private List<Item> myItems;
private XPathContext myCtxt;
/** The namespace used for the elements. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ public Sequence next()
Item item;
try {
item = myIt == null ? null : myIt.next();
return new SaxonSequence(item.iterate(), myCtxt);
}
catch ( XPathException ex ) {
throw new HttpClientException("Error getting the next item in the sequence", ex);
}
SequenceIterator it = SingletonIterator.makeIterator(item);
return new SaxonSequence(it, myCtxt);
}

@Override
Expand Down
Loading