-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from ndw/dev
Add extension functions to the distribution
- Loading branch information
Showing
289 changed files
with
1,227 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// This Gradle script builds the extension functions for the build process | ||
|
||
plugins { | ||
id "java" | ||
} | ||
|
||
repositories { | ||
maven { url uri('/tmp/repo') } | ||
mavenLocal() | ||
mavenCentral() | ||
maven { url "http://maven.restlet.org" } | ||
} | ||
|
||
dependencies { | ||
compile ( | ||
[group: 'com.nwalsh', name: 'nwalsh-annotations', version: '1.0.0'], | ||
[group: 'net.sf.saxon', name: 'Saxon-HE', version: "9.8.0-8"], | ||
) | ||
} |
70 changes: 70 additions & 0 deletions
70
buildSrc/src/main/java/org/docbook/extensions/xslt20/Cwd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.docbook.extensions.xslt20; | ||
|
||
|
||
import com.nwalsh.annotations.SaxonExtensionFunction; | ||
import net.sf.saxon.expr.XPathContext; | ||
import net.sf.saxon.lib.ExtensionFunctionCall; | ||
import net.sf.saxon.lib.ExtensionFunctionDefinition; | ||
import net.sf.saxon.om.Sequence; | ||
import net.sf.saxon.om.StructuredQName; | ||
import net.sf.saxon.trans.XPathException; | ||
import net.sf.saxon.value.AnyURIValue; | ||
import net.sf.saxon.value.SequenceType; | ||
|
||
/** | ||
* Saxon extension to get the current working directory. | ||
* | ||
* This class provides a | ||
* <a href="http://saxonica.com/">Saxon</a> | ||
* extension to return the current working directory (the user.dir system property). | ||
* | ||
* <p>Copyright © 2011-2018 Norman Walsh. | ||
* | ||
* @author Norman Walsh | ||
* <a href="mailto:[email protected]">[email protected]</a> | ||
*/ | ||
@SaxonExtensionFunction | ||
public class Cwd extends ExtensionFunctionDefinition { | ||
private static final StructuredQName qName = | ||
new StructuredQName("", "http://docbook.org/extensions/xslt20", "cwd"); | ||
|
||
@Override | ||
public StructuredQName getFunctionQName() { | ||
return qName; | ||
} | ||
|
||
@Override | ||
public int getMinimumNumberOfArguments() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getMaximumNumberOfArguments() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public SequenceType[] getArgumentTypes() { | ||
// If it takes no arguments, what's this for? | ||
return new SequenceType[]{SequenceType.OPTIONAL_NUMERIC}; | ||
} | ||
|
||
@Override | ||
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { | ||
return SequenceType.SINGLE_ATOMIC; | ||
} | ||
|
||
public ExtensionFunctionCall makeCallExpression() { | ||
return new CwdCall(); | ||
} | ||
|
||
private class CwdCall extends ExtensionFunctionCall { | ||
public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException { | ||
String dir = System.getProperty("user.dir"); | ||
if (!dir.endsWith("/")) { | ||
dir += "/"; | ||
} | ||
return new AnyURIValue(dir); | ||
} | ||
} | ||
} |
Oops, something went wrong.