Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Saxon 10, 11, 12 support #8 #81

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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 .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# note that Saxon license should not be added to git but you may need it locally for testing
[saxon-license.lic]
charset = latin1

[*.{yml,yaml}]
indent_size = 2

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ build/
*.iml

# Ignore the output of the Ant build
barcode4j/dist/
barcode4j/dist/

# If a Saxon license is used for testing make sure it's not added
saxon-license.lic
82 changes: 82 additions & 0 deletions barcode4j-saxon/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.singingbush</groupId>
<artifactId>barcode4j-parent</artifactId>
<version>2.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>barcode4j-saxon</artifactId>
<name>Barcode4J Saxon (PE &amp; EE 10 and above)</name>
<description>Support for Saxon PE and EE (should work with Saxon 10.6.* to 12.*)</description>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>

<!-- Saxon EE could be pulled from the maven.saxonica.com repo -->
<!-- See: https://maven.saxonica.com/maven/com/saxonica/Saxon-EE/index.html -->
<!-- Once EE is working then it should be good for version 10.* to 12.* -->
<!-- <saxon.version>10.2</saxon.version>-->
<saxon.version>10.6</saxon.version>
<!-- <saxon.version>10.9</saxon.version>-->
<!-- <saxon.version>11.1.1</saxon.version>-->
<!-- <saxon.version>11.6</saxon.version>-->
<!-- <saxon.version>12.5</saxon.version>-->
</properties>

<dependencies>
<dependency>
<groupId>com.singingbush</groupId>
<artifactId>barcode4j</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>com.saxonica</groupId>
<artifactId>Saxon-EE</artifactId>
<version>${saxon.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<!-- don't publish barcode4j-saxon until it's confirmed working -->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>saxonica</id>
<name>Saxonica</name>
<url>https://dev.saxonica.com/maven/</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2003-2012 Jeremias Maerki.
* Copyright 2020-2024 Samael Bate (singingbush)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.krysalis.barcode4j.saxon;

import com.saxonica.xsltextn.ExtensionElementFactory;
import net.sf.saxon.style.StyleElement;

/**
* This class represents the element factory for the barcode extension for Saxon.
* <p>
* Later releases of Saxon are split into 3 versions:
* </p>
* <ul>
* <li>Saxon-HE (Home Edition) available on maven central</li>
* <li>Saxon-PE (Professional Edition) available from Saxonica maven repo &amp; requires license</li>
* <li>Saxon-EE (Enterprise Edition) available from Saxonica maven repo &amp; requires license</li>
* </ul>
* <p>
* Saxonica only provide support for element extensibility in the EE and PE releases.
* From version 10 onward, instead of implementing "net.sf.saxon.style.ExtensionElementFactory"
* use "com.saxonica.xsltextn.ExtensionElementFactory"
* </p>
* @author Jeremias Maerki &amp; Samael Bate (singingbush)
* @see com.saxonica.xsltextn.ExtensionElementFactory
*/
public class BarcodeExtensionElementFactory implements ExtensionElementFactory {

/**
* @see com.saxonica.xsltextn.ExtensionElementFactory#getExtensionClass(java.lang.String)
*/
@Override
public Class<? extends StyleElement> getExtensionClass(String localName) {
return localName.equals("barcode") ? BarcodeStyleElement.class : BarcodeNonRootStyleElement.class;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2003-2012 Jeremias Maerki.
* Copyright 2020-2024 Samael Bate (singingbush)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.krysalis.barcode4j.saxon;

import net.sf.saxon.expr.Expression;
import net.sf.saxon.style.Compilation;
import net.sf.saxon.style.ComponentDeclaration;
import net.sf.saxon.style.StyleElement;
import net.sf.saxon.trans.XPathException;

/**
* Non-root barcode elements.
*
* @author Jeremias Maerki &amp; Samael Bate (singingbush)
*/
public class BarcodeNonRootStyleElement extends StyleElement {

/**
* @see StyleElement#prepareAttributes()
*/
@Override
public void prepareAttributes() {
//nop
}

@Override
public Expression compile(Compilation compilation, ComponentDeclaration decl) throws XPathException {
return null;
}

/*
* @see net.sf.saxon.style.StyleElement#compile(net.sf.saxon.expr.instruct.Executable)
*/
// @Override
// public Expression compile(Executable exec) throws XPathException {
// return null;
// }

}
Loading
Loading