Skip to content
Commits on Source (3)
Changes in V3.0.2 since V3.0.1
* XMLBEANS-520: wrong name for source(s) artifact
* XMLBEANS-519: issue when using old XML parser versions
* XMLBEANS-506: NPE trying to load resource file if XmlBeans was loaded by the bootstrap ClassLoader
Changes in V3.0.1 since V3.0.0
* XMLBEANS-518: add support to XmlOptions to allow control over the XML parser settings that affect DTD loading
and entity expansion
Changes in V3.0.0 since V2.6.0
* XMLBEANS-517: use safe XML parsers
* XMLBEANS-516: remove unnecessary javax and org.w3c classes
* XMLBEANS-515: remove piccolo support
* XMLBEANS-514: make java 6 the lowest supported runtime
* XMLBEANS-489: fix for Cursor getAllNamespaces not returning default namespace
* Fix for XMLBEANS-499: xmlbeans2.6.0.jar contains duplicate class files (causes issues
on Android)
* XMLBEANS-447: Drop the ConcurrentReaderHashMap source code
* Fix for XMLBEANS-404: entitizeContent CDATA loop iterating too many times (causes
assertion error or ArrayIndexOutOfBoundsException in replace)
* Fix for XMLBEANS-332: XMLBeans changes surrogate pair bytes to question marks
Changes in V2.6.0 since V2.5.0
* Add new xml option CopyUseNewSynchronizationDomain used for copy.
This fixes the scenario when copy and access (ex. selectPath) are used
in a multithreading environment.
* Entitize \r when not in pretty print, this helps with maintaining \r
entities.
* Fix validation of integer value containing dot char.
* Fix chars in comments to avoid errors in IntelliJ under linux.
* Update durations to latest spec.
* Fix for compiling schema that contains complex type with simple
content that has facets defined in the base simple type
* Fix for Piccolo lexer when read method returns 0.
* Fix to preserve the CDATA bookmarks when copy from one xmlobject to
another.
* Fix bug when resizing circular buffer in saver's output stream
implementation.
* Fix for bug when not specifing type for a particle in derived schema
type and when minOccurs is 0.
* Fixed error messages when contain base and derived type names.
* Introducing a default maximum entity replacement limit of 10kb, it can
be controled by using the option XmlOptions.setLoadEntityBytesLimit.
* Fixed javadoc for inst2xsd and xsd2inst tools.
* Fix NPE in SchemaTypeImpl.getEnumJavaClass().
* Added multiple entry points and refactored code for xsd2inst code.
* Remove org.w3c.dom files from xbean.jar.
* Add another xpath and xquery interface implementation.
* Add src/xmlinputstream classes org.apache.xmlbeans.xml.stream.* to
xmlpublic.jar.
* Make bootstrap run twice to avoid GUMP error emails.
* Fix for bug XMLBEANS-396: GML 3.1.1 generated code fails to compile.
* Fix for bug XMLBEANS-412: Pattern facet regex requires dash - to be
escaped.
* Fix for bug XMLBEANS-414: error cvc-complex-type.2.1: Element 'XXXX'
with empty content type cannot have text or element content.
Changes in V2.5.0 since V2.4.0
* Exit codes for InstanceValidator
* Decimal precision handling fix in xsd2inst
* Option to perform additional, stricter Schema validation checks: XMLBEANS-350
* updated pattern for dayTimeDuration
* Extended year min/max value limitations
* Support for date and time types with hour 24.
* NOTATION built-in type
* DocType fix when root element is changed
* "User types" feature - allows mapping of Schema simple types to custom user Java classes
http://wiki.apache.org/xmlbeans/UserTypes
* Nested enumeration type compilation error fix: XMLBEANS-381
* Deadlock fix in generated impl setter simple and array
* Required attribute fix in streaming validator
* Many other fixes and optimizations
Changes in V2.4.0 since V2.3.0
* Pluggable XPath/XQuery engine support
* Upgraded support for Saxon 9
* Added Schema compilation option to skip errors in case duplicate component declarations are encountered.
* Finer grained support for CDATA
* Tool to generate XPath for a given cursor position in a document
* added more fine-grained control over XML to Java name mapping
* Add support for JVM-supported encodings
* Adding XmlError codes
* Replace static HashMaps with WeakHashMaps
* Fix for XMLBEANS-309 Warnings on Generated code
* Fix for XMLBEANS-361 invalid NaN comparisons
* Fix qname marshaling when empty namespace
* Various other bug fixes
Changes in V2.3.0 since V2.2.0
* Improved Saxon support, Saxon 8.8 became the recommended version
* Added options to control use of CDATA sections when saving to XML
* Added support for QNames in Schema annotations
* Added support for new encodings: UTF-16LE, UTF-16BE, CP936/GBK.
* Fix: overzealous whitespace cropping after parsing entities like & (XMLBEANS-274)
* Fix: selectPath() with setXqueryCurrentNodeVar() option does not work for Saxon (XMLBEANS-276)
* Fix: synchronization problem with array setters
* Fix: Saver$TextSaver.replace method throws java.lang.ArrayIndexOutOfBoundsException (XMLBEANS-209)
* Fix: QNameSet generated by QNameSet.forArray(QName[]) can't be unioned with other QNameSets (XMLBEANS-290)
* Fix: java.lang.ArrayIndexOutOfBoundsException when saving XML (XMLBEANS-291)
* Fix: XQuery gives wrong result with Saxon 8.6.1 (XMLBEANS-275)
* Fix: bug during generation of complex types with simple content
* Fix: improved error handling during loading of Schema type system
* Fix: bugs in Duration serialization
* Fix: XMLCursor.getTextValue()
* Fix: Remove year zero from GDate, GDateBuilder and XmlCalendar per XMLSchema spec D.3.2
Changes in v2.2.0 since v2.1.0:
* Allow polymorphism in Extension Interfaces Feature
* Fix for circular buffer in TextSaver
* Tuned synchronization for multithreaded validation
* Updated to the latest XMLSchema.xsd - January 25, 2006
* Better QName validation
* Fix insertion positions when using substitution groups with arrays
* Updated XmlBeans to work with SaxonB-8.6.1 in place of SaxonB8.1
* Fix for regex validation in multi-threaded, multi-processor environment
* Fix for schema compilation error when restricting complex type with simple content
* Implemented XMLInputStream interface for saving a store
* XQuery external variable binding support
* Various other bug fixes
Changes in v2.1.0 since v2.0.0:
* Fixed the issue whereby some IDEs would have problems with the TypeSystemHolder class being generated in the classes directory
* Better integration with Maven
* Implemented support for ID/IDREF in DTDs via DOM's .getElementByID()
* Integrated a patch that makes XmlBeans work in a sandboxed environment
* Added the ability to control entitization of characters when saving documents
* Fixed issue with memory reclamation in multi-threaded environments, which was delayed too much so it could be mistaken for a memory leak
* Added numerous new test cases and performance tests
* Continued improving performance, especially in the DOM support and XmlCursor areas
* Added column numbers support in our snapshot of Piccolo; validation and XMLSchema error reporting benefit from this and is of course usable from user code
* Line/column number is now also available for end-tags
* Solved a legal inconsistency surrounding our use of JSR173 APIs
* Fixed a lot of reported issues in various areas of the product
Changes in v2.0.0 since v2.0.0-beta1:
* many performance related changes, especialy in the DOM and Cursor areas
* rewrite of the <xs:redefine> support
* Completed the implementation of Filer
* new documentation on xs:any, validation plus updates of the old docs
* many bug fixes, including perm gen memory bug
Changes in v2.0.0-beta1:
* new store implementation, including native DOM implementation
* Piccolo is now the default parser.XmlOptions.setLoadUseXMLReader (XMLReader xmlReader) can be used when a diffrent parser is required.
* Sample xml generation from an schema file
* New failfast behavior for simple types, more consistent
* EntityResolver is setable in SchemaCompiler
* XPath 2.0 and Xquery support through Saxon
* java 1.5 generics for array properties added to generated source
* Simplified working with substitution groups by adding XmlObject.substitute() method
* "-noVDoc" command-line option for scomp to skip validation of <xs:documentation> contents
* uniform access to the getSourceName() method in Schema Object Model
* Cleaned up schema compilation APIs with a XmlBeans.compileXmlBeans()
* Added error codes and improved validation error messages
* Changed .xsb format and loading strategy to improve performance
* Ability to pass URLs instead of Files for Wsdl/Schemas
* Added option to pass in "##local" to -allowmdef
* Inst2xsd: support for xsi:nil and qname fix.
* adding getCurrentElementSchemaType in Validator for finding schema types of elements with xsi:type attribute
* adding ValidatingInfoXMLStreamReader for PSVI access on XMLStreamReaders
* added Location to streaming validation errors
* Instance 2 schema tool
* Support for arbitrarily nesting <xsd:redefine>s
* New "schema bookmark" mechanism allowing one to tag user data on Schema Object Model entities
* Add ability for XmlSaxHandler to insert bookmarks while loading
* Added a diff utility that compares two jars (or directories) containing compiled Schema types
* Interface and pre-post extensions
* Enabled ValidatingXMLStreamReader to start validating from both current and next event in the XMLStreamReader
* Functionality to retrieve xml validation errors programatically
* Added saver options to not save xml decl
* Added ability to compile Schemas containing references to SOAP11 encoded arrays
* selectChildren and selectAttributes for dynamic getters and some wildcard scenarios
* Location in ValidatingXmlStreamReader
* Added a wrapper over jsr173's XMLStreamReader
* Added support for default value in XMLStreamReaderExt interface and implementation
* Adding typed value for QName case in the Validator
* Adding an utility for validation of simple schema types
* Improved the Validator to ofer PSVI info
* Exposed some of the XMLSchema validator functionality in the public interfaces
* Added support for XML Catalog, based on Apache Commons CatalogResolver
* Added XMLStreamReaderExt an extention of XMLStreamReader which alowes getting strongly typed java values from a stream
* Adds support for annotations in XMLSchema
* Added JSR 173 support
* performance tests
* various feature tests
* samples and documentation
* packaging, licencing changes
This diff is collapsed.
File mode changed from 100644 to 100755
......@@ -3,7 +3,7 @@
== Version 2.0, in this case for the Apache XmlBeans distribution. ==
=========================================================================
This product includes software developed by
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Portions of this software were originally based on the following:
......@@ -22,8 +22,3 @@
- resolver.jar from Apache Xml Commons project,
Copyright (c) 2001-2003 Apache Software Foundation
- Piccolo XML Parser for Java from http://piccolo.sourceforge.net/,
Copyright 2002 Yuval Oren under the terms of the Apache Software License 2.0
- JSR-173 Streaming API for XML from http://sourceforge.net/projects/xmlpullparser/,
Copyright 2005 BEA under the terms of the Apache Software License 2.0
Project Homepage:
http://xmlbeans.apache.org/
Active committers:
Cezar Andrei cezar at apache dot org
Radu Preotiuc-Pietro radu.preotiuc-pietro at oracle dot com
Jacob Danner jacob dot danner at gmail.com
Wing Yew Poon wing.yew.poon at oracle dot com
FAQ:
http://wiki.apache.org/xmlbeans/XmlBeansFaq
This diff is collapsed.
Some brief instructions for using the maven xmlbeans2 plugin
1. Include something like this in your maven.xml:
namespace declaration:
xmlns:xmlbeans="xmlbeans:maven"
<preGoal name="java:compile">
<xmlbeans:schema2java
sourcedir="${basedir}/src"
sourceschema="j2ee_1_4schema/application_1_4.xsd,j2ee_1_4schema/j2ee_jaxrpc_mapping_1_1.xsd,j2ee_1_3schema/connector_1_0.xsd"
xmlconfigs="${basedir}/src/conf/xmlconfig.xml"
targetdir="${basedir}/target/xmlbeans"
cataloglocation="${basedir}/src/catalog/resolver-catalog.xml"/>
</preGoal>
where
sourcedir is a base directory for the list in sourceschema
sourceschema is a comma-delimited list of all the schemas you want to compile
xmlconfigs points to your xmlconfig.xml file
targetdir is where you want generated java source to appear
cataloglocation is the location of an entity resolver catalog to use for resolving namespace to schema locations.
The generated binary files, both .xsd and the TypeHolder class, will end up in the target/classes directory.
In addition, you can add precompiled schemas to the "schema classpath" by including them as
dependencies in project.xml with a properties tag like this:
<dependency>
<groupId>geronimo</groupId>
<artifactId>geronimo-naming-builder</artifactId>
<version>${pom.currentVersion}</version>
<properties>
<xmlbeans>true</xmlbeans>
</properties>
</dependency>
You will probably also want to add a dependency on the plugin to your project.xml file and the other dependencies if you use xmlbeans in unit tests:
<dependency>
<groupId>xmlbeans</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.0-beta1</version>
<type>plugin</type>
</dependency>
<!-- needed for xmlbeans runtime-->
<dependency>
<groupId>xmlbeans</groupId>
<artifactId>xbean</artifactId>
<version>${xmlbeans_version}</version>
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax</artifactId>
<version>${stax_version}</version>
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>${stax_api_version}</version>
</dependency>
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
......
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
<?xml version="1.0"?>
<!--
Copyright 2004-2005 The Apache Software Foundation
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.
-->
<!-- ================================================================== -->
<!-- xmlbeans v2 maven plugin -->
<!-- ================================================================== -->
<project xmlns:j="jelly:core"
xmlns:u="jelly:util"
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:define="jelly:define"
xmlns:xmlbeans="xmlbeans2:maven"
>
<define:taglib uri="xmlbeans2:maven">
<define:jellybean
name="SchemaCompilerWrapper"
className="org.apache.xmlbeans.maven.SchemaCompilerWrapper"
method="compileSchemas"/>
<define:tag name="schema2java" xmlns="jelly:ant">
<j:if test="${context.getVariable('maven.xmlbeans2.targetdir') == null}">
<fail>Missing required attribute: maven.xmlbeans2.targetdir</fail>
</j:if>
<j:if test="${context.getVariable('maven.xmlbeans2.sourcedir') == null}">
<fail>Missing required attribute: maven.xmlbeans2.sourcedir</fail>
</j:if>
<j:if test="${context.getVariable('maven.xmlbeans2.sourceschema') == null}">
<fail>Missing required attribute: maven.xmlbeans2.sourceschema</fail>
</j:if>
<j:if test="${context.getVariable('maven.xmlbeans2.xmlconfigs') == null}">
<fail>Missing required attribute: maven.xmlbeans2.xmlconfigs</fail>
</j:if>
<!-- set up classpath for already-compiled schemas -->
<j:forEach var="artifact" items="${pom.artifacts}">
<j:set var="dependency" value="${artifact.dependency}"/>
<j:if test="${dependency.getProperty('xmlbeans') == 'true'}">
<j:set var="xmlbeans.classpath" value="${xmlbeans.classpath},${artifact.path}"/>
</j:if>
</j:forEach>
<j:jelly xmlns="jelly:ant">
<j:set var="uptodatePropName" value="xmlbeans.uptodate"/>
<j:expr value="${context.setVariable(uptodatePropName, null)}"/>
<j:set var="uptodateFile" value="${maven.xmlbeans2.targetdir}/tstamp"/>
<uptodate property="${uptodatePropName}"
targetfile="${uptodateFile}">
<srcfiles dir="${maven.xmlbeans2.sourcedir}"
includes="${maven.xmlbeans2.sourceschema}"/>
</uptodate>
<xmlbeans:SchemaCompilerWrapper
sourceDir="${maven.xmlbeans2.sourcedir}"
sourceSchemas="${maven.xmlbeans2.sourceschema}"
xmlConfigs="${maven.xmlbeans2.xmlconfigs}"
javaTargetDir="${maven.xmlbeans2.targetdir}"
classTargetDir="${maven.build.dest}"
catalogLocation="${maven.xmlbeans2.cataloglocation}"
classPath="${xmlbeans.classpath}"
resources="${pom.build.resources}"
buildSchemas="${context.getVariable(uptodatePropName) == null}"
baseSchemaLocation="${maven.xmlbeans2.baseSchemaLocation}"
/>
<j:if test="${context.getVariable(uptodatePropName) == null}">
<touch file="${uptodateFile}"/>
</j:if>
<path id="maven.xmlbeans.compile.src.set"
location="${maven.xmlbeans2.targetdir}"/>
<j:if test="${context.antProject.getReference('maven.compile.src.set') != null}">
<maven:addPath id="maven.compile.src.set"
refid="maven.xmlbeans.compile.src.set"/>
</j:if>
<j:if test="${context.antProject.getReference('maven.compile.src.set') == null}">
<echo message="Maven cannot find the generated sources unless you provide a dummy source directory in project.xml"/>
</j:if>
</j:jelly>
</define:tag>
</define:taglib>
</project>
\ No newline at end of file
# Copyright 2003-2005 The Apache Software Foundation
#
# 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.
#These properties can be set in a project.properties file or in an invocation in maven.xml
#dependencies marked with the property <xmlbeans>true</xmlbeans> will get included in the xmlbeans classpath
#so you can reuse your xmlbeans generated classes.
#a typical invocation looks like:
#<project default="default"
# xmlns:xmlbeans="xmlbeans2:maven">
#
# <preGoal name="java:compile">
# <xmlbeans:schema2java
# maven.xmlbeans2.sourceschema="application_1_4.xsd,j2ee_jaxrpc_mapping_1_1.xsd"
# maven.xmlbeans2.cataloglocation="${basedir}/src/catalog/resolver-catalog.xml"/>
# </preGoal>
#base location for schemas to compile
maven.xmlbeans2.sourcedir=${basedir}/src/schema
#comma separated list of schemas to compile, relative to sourcedir above. You must specify this explicitly
maven.xmlbeans2.sourceschema=
#location of the xmlbeans configuration file
maven.xmlbeans2.xmlconfigs=${basedir}/src/schema/xmlconfig.xml
#location of an xml catalog. If you use one, you must specify the location yourself.
maven.xmlbeans2.cataloglocation=
#target directory for generated java code. Binary artifacts are place directly into target/classes.
maven.xmlbeans2.targetdir=${basedir}/target/xmlbeans
#default base location where schemas will be copied. Unlike the ant task,
#they will include the path of the schema listed in the sourceSchemas parameter.
maven.xmlbeans2.baseSchemaLocation=schemaorg_apache_xmlbeans/src
# Copyright 2003-2005 The Apache Software Foundation
#
# 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.
maven.multiproject.type=plugin
maven.repo.central=apache.org
maven.repo.central.directory=/www/cvs.apache.org/repository
maven.remote.group=apcvs
maven.compile.source=1.4
maven.compile.target=1.4
#maven.compile.deprecation=true
maven.compile.debug=true
maven.compile.optimize=true
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation
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.
-->
<project>
<pomVersion>3</pomVersion>
<groupId>xmlbeans</groupId>
<id>xmlbeans-maven-plugin</id>
<currentVersion>2.0.0-beta1</currentVersion>
<name>xmlbeans maven plugin</name>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
<logo></logo>
</organization>
<inceptionYear>2004</inceptionYear>
<package>org.apache.xmlbeans.maven</package>
<logo></logo>
<dependencies>
<dependency>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>xmlbeans</groupId>
<artifactId>xbean</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/java</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources>
<resource>
<directory>src/plugin-resources</directory>
<targetPath>plugin-resources</targetPath>
</resource>
<resource>
<directory>.</directory>
<includes>
<include>plugin.jelly</include>
<include>plugin.properties</include>
<include>project.properties</include>
<include>project.xml</include>
</includes>
</resource>
</resources>
</build>
</project>
/**
*
* Copyright 2003-2005 The Apache Software Foundation
*
* 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.apache.xmlbeans.maven;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.apache.maven.project.Resource;
import org.apache.xml.resolver.CatalogManager;
import org.apache.xml.resolver.tools.CatalogResolver;
import org.apache.xmlbeans.impl.tool.SchemaCompiler;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
*
*
* @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
*
* */
public class SchemaCompilerWrapper {
private String sourceDir;
private String sourceSchemas;
private String xmlConfigs;
private String javaTargetDir;
private String classTargetDir;
private String catalogLocation;
private String classPath;
private List resources;
private boolean buildSchemas;
//this copy should not end in /
private String baseSchemaLocation = "schemaorg_apache_xmlbeans/src";
public String getSourceDir() {
return sourceDir;
}
public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}
public String getSourceSchemas() {
return sourceSchemas;
}
public void setSourceSchemas(String sourceSchemas) {
this.sourceSchemas = sourceSchemas;
}
public String getXmlConfigs() {
return xmlConfigs;
}
public void setXmlConfigs(String xmlConfigs) {
this.xmlConfigs = xmlConfigs;
}
public String getJavaTargetDir() {
return javaTargetDir;
}
public void setJavaTargetDir(String javaTargetDir) {
this.javaTargetDir = javaTargetDir;
}
public String getClassTargetDir() {
return classTargetDir;
}
public void setClassTargetDir(String classTargetDir) {
this.classTargetDir = classTargetDir;
}
public String getCatalogLocation() {
return catalogLocation;
}
public void setCatalogLocation(String catalogLocation) {
this.catalogLocation = catalogLocation;
}
public String getClassPath() {
return classPath;
}
public void setClassPath(String classPath) {
this.classPath = classPath;
}
public List getResources() {
return resources;
}
public void setResources(List resources) {
this.resources = resources;
}
public boolean isBuildSchemas() {
return buildSchemas;
}
public void setBuildSchemas(boolean buildSchemas) {
this.buildSchemas = buildSchemas;
}
public String getBaseSchemaLocation() {
return baseSchemaLocation;
}
public void setBaseSchemaLocation(String baseSchemaLocation) {
if (baseSchemaLocation != null && !(baseSchemaLocation.length() == 0)) {
this.baseSchemaLocation = baseSchemaLocation;
}
}
public void compileSchemas() throws Exception {
List schemas = new ArrayList();
File base = new File(sourceDir);
Resource resource = new Resource();
resource.setDirectory(sourceDir);
resource.setTargetPath(baseSchemaLocation);
for (StringTokenizer st = new StringTokenizer(sourceSchemas, ","); st.hasMoreTokens();) {
String schemaName = st.nextToken();
schemas.add(new File(base, schemaName));
resource.addInclude(schemaName);
}
resources.add(resource);
if (buildSchemas) {
List configs = new ArrayList();
if (xmlConfigs != null) {
for (StringTokenizer st = new StringTokenizer(xmlConfigs, ","); st.hasMoreTokens();) {
String configName = st.nextToken();
configs.add(new File(configName));
}
}
List classPathList = new ArrayList();
List urls = new ArrayList();
if (classPath != null) {
for (StringTokenizer st = new StringTokenizer(classPath, ","); st.hasMoreTokens();) {
String classpathElement = st.nextToken();
File file = new File(classpathElement);
classPathList.add(file);
urls.add(file.toURL());
System.out.println("Adding to classpath: " + file);
}
}
ClassLoader cl = new URLClassLoader((URL[]) urls.toArray(new URL[] {}));
EntityResolver entityResolver = null;
if (catalogLocation != null) {
CatalogManager catalogManager = CatalogManager.getStaticManager();
catalogManager.setCatalogFiles(catalogLocation);
entityResolver = new CatalogResolver();
}
URI sourceDirURI = new File(sourceDir).toURI();
entityResolver = new PassThroughResolver(cl, entityResolver, sourceDirURI, baseSchemaLocation);
SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
params.setBaseDir(null);
params.setXsdFiles((File[])schemas.toArray(new File[] {}));
params.setWsdlFiles(new File[] {});
params.setJavaFiles(new File[] {});
params.setConfigFiles((File[])configs.toArray(new File[] {}));
params.setClasspath((File[])classPathList.toArray(new File[] {}));
params.setOutputJar(null);
params.setName(null);
params.setSrcDir(new File(javaTargetDir));
params.setClassesDir(new File(classTargetDir));
params.setCompiler(null);
params.setMemoryInitialSize(null);
params.setMemoryMaximumSize(null);
params.setNojavac(true);
params.setQuiet(false);
params.setVerbose(true);
params.setDownload(false);
params.setNoUpa(false);
params.setNoPvr(false);
params.setDebug(true);
params.setErrorListener(new ArrayList());
params.setRepackage(null);
params.setExtensions(null);
params.setMdefNamespaces(null);
params.setEntityResolver(entityResolver);
boolean result = SchemaCompiler.compile(params);
if (!result) {
Collection errors = params.getErrorListener();
for (Iterator iterator = errors.iterator(); iterator.hasNext();) {
Object o = (Object) iterator.next();
System.out.println("xmlbeans error: " + o);
}
throw new Exception("Schema compilation failed");
}
}
}
private static class PassThroughResolver implements EntityResolver {
private final ClassLoader cl;
private final EntityResolver delegate;
private final URI sourceDir;
//this copy has an / appended
private final String baseSchemaLocation;
public PassThroughResolver(ClassLoader cl, EntityResolver delegate, URI sourceDir, String baseSchemaLocation) {
this.cl = cl;
this.delegate = delegate;
this.sourceDir = sourceDir;
this.baseSchemaLocation = baseSchemaLocation + "/";
}
public InputSource resolveEntity(String publicId,
String systemId)
throws SAXException, IOException {
if (delegate != null) {
InputSource is = delegate.resolveEntity(publicId, systemId);
if (is != null) {
return is;
}
}
System.out.println("Could not resolve publicId: " + publicId + ", systemId: " + systemId + " from catalog");
String localSystemId;
try {
localSystemId = sourceDir.relativize(new URI(systemId)).toString();
} catch (URISyntaxException e) {
throw (IOException)new IOException("Could not relativeize systemId").initCause(e);
}
InputStream in = cl.getResourceAsStream(localSystemId);
if (in != null) {
System.out.println("found in classpath at: " + localSystemId);
return new InputSource(in);
}
in = cl.getResourceAsStream(baseSchemaLocation + localSystemId);
if (in != null) {
System.out.println("found in classpath at: META-INF/" + localSystemId);
return new InputSource(in);
}
System.out.println("Not found in classpath, looking in current directory: " + systemId);
return new InputSource(systemId);
}
}
}
......@@ -70,7 +70,7 @@
<path refid="xmlbeans.classpath"/>
</classpath>
</scomp>
<javac srcdir="src" destdir="build" debug="on" source="1.4">
<javac srcdir="src" destdir="build" debug="on" source="1.6">
<classpath>
<path refid="xmlbeans.classpath"/>
<pathelement location="build/${abstract.jar}"/>
......
......@@ -89,7 +89,7 @@ limitations under the License.
destdir="build/classes"
classpathref="Any.path"
debug="on"
source="1.4"
source="1.6"
/>
</target>
......