release version 1.10.0

This commit is contained in:
2024-12-14 04:07:49 +03:00
parent a5088587f7
commit c6b3d793c4
1916 changed files with 254306 additions and 0 deletions

View File

@ -0,0 +1,68 @@
====
Copyright (C) 2017 Oracle
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.
====
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.
#
# The contents of this file are subject to the terms of either the GNU
# General Public License Version 2 only ("GPL") or the Common Development
# and Distribution License("CDDL") (collectively, the "License"). You
# may not use this file except in compliance with the License. You can
# obtain a copy of the License at
# http://glassfish.java.net/public/CDDL+GPL_1_1.html
# or packager/legal/LICENSE.txt. See the License for the specific
# language governing permissions and limitations under the License.
#
# When distributing the software, include this License Header Notice in each
# file and include the License file at packager/legal/LICENSE.txt.
#
# GPL Classpath Exception:
# Oracle designates this particular file as subject to the "Classpath"
# exception as provided by Oracle in the GPL Version 2 section of the License
# file that accompanied this code.
#
# Modifications:
# If applicable, add the following below the License Header, with the fields
# enclosed by brackets [] replaced by your own identifying information:
# "Portions Copyright [year] [name of copyright owner]"
#
# Contributor(s):
# If you wish your version of this file to be governed by only the CDDL or
# only the GPL Version 2, indicate your decision by adding "[Contributor]
# elects to include this software in this distribution under the [CDDL or GPL
# Version 2] license." If you don't indicate a single choice of license, a
# recipient has the option to distribute your version of this file under
# either the CDDL, the GPL Version 2 or to extend the choice of license to
# its licensees as provided above. However, if you add GPL Version 2 code
# and therefore, elected the GPL Version 2 license, then the option applies
# only if the new code is made subject to such option by the copyright
# holder.
#
From 1.0 (2003/04/03)
=====================
- Fixed a bug in the parsing of:
<xs:element name="foo" substitutionGroup="bar" />
(2003/04/04)
- AnnotationParser was changed from an interface to an abstract class.
This allows future versions to add new methods without breaking
existing clients.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -0,0 +1,186 @@
<html>
<head>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
http://glassfish.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<title>Design of XSOM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<style>
pre {
background-color: rgb(240,240,240);
margin-left: 2em;
margin-right: 2em;
padding: 1em;
}
p {
margin-left: 2em;
}
dt {
margin-top: 0.5em;
margin-left: 2em;
font-weight: bold;
}
dd {
margin-left: 3em;
}
</style>
</head>
<body>
<h1 style="text-align:center">Design of XSOM</h1>
<div align=right style="font-size:smaller">
By <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke Kawaguchi</a><br>
</div>
<p>
This document describes the details you need to know to extend/maintain XSOM.
</p>
<h1>Design Goals</h1>
<p>
The primary design goals of XSOM are:
</p>
<ol>
<li>Expose all the information defined in the schema spec
<li>Provide additional methods that helps simplifying client applications.
</ol>
<p>
Providing mutation methods was a non-goal for this project, primarily because of the added complexity.
</p>
<h1>Building workspace</h1>
<p>
The workspace uses Ant as the build tool. The followings are the major targets:
</p>
<dl>
<dt>clean</dt>
<dd>remove the intermediate and output files.</dd>
<dt>compile</dt>
<dd>generate a parser by RelaxNGCC and compile all the source files into the bin directory.</dd>
<dt>jar</dt>
<dd>make a jar file</dd>
<dt>release</dt>
<dd>build a distribution zip file that contains everything from the source code to a binary file</dd>
<dt>src-zip</dt>
<dd>Build a zip file that contains the source code.</dd>
</dl>
<h1>Architecture</h1>
<p>
XSOM consists of roughly three parts.
The first part is the public interface, which is defined in the <code>com.sun.xml.xsom</code> package. The entire functionality of XSOM is exposed via this interface. This interface is derived from a draft document submitted to W3C by some WG members.
</p><p>
The second part is the implementation of these interfaces, the <code>com.sun.xml.xsom.impl</code> package. These code are all hand-written.
</p><p>
The third part is a parser that reads XML representation of XML Schema and builds XSOM nodes accordingly. The package is <code>com.sun.xml.xsom.parser</code>. This part of the code is mostly generated by <a href="http://relaxngcc.sourceforge.net/">RelaxNGCC</a>.
</p>
<center>
<img src="architecture.png"/>
</center>
<h1>Implementation Details</h1>
<p>
Most of the implementation classes are fairly simple. Probably the only one interesting piece of code is the <code>Ref</code> class, which is a reference to other schema components.
</p><p>
The <code>Ref</code> class itself is just a place hodler and this class defined a series of inner interfaces that are specialized to hold a reference to different kinds of schema components.
The sole purpose of this indirection layer is to support forward references during a parsing of the XML representation.
</p><p>
A typical reference interface would look like this:
</p>
<pre>
public static interface Term {
/** Obtains a reference as a term. */
XSTerm getTerm();
}
</pre>
<p>
In case this indirection is unnecessary, all implementation classes of <code>XSTerm</code> implements this <code>Ref.Term</code> interface. This applies to all the other types of the <code>Ref</code> interface. Therefore, whereever a reference is necessary, you can stimply pass a real object. In other words, a direct reference (<code>XS***Impl</code>) can be always treated as an indirect reference (<code>Ref.***</code>).
</p><p>
Implementations for forward references are placed in the <code>com.sun.xml.xsom.impl.parser.DelayedRef</code> class. The detail will be discussed later.
</p>
<h1>Parser</h1>
<p>
The following collaboration diagram shows various objects that participate in a parsing process.
</p>
<center>
<img src="collaboration.png"/>
</center>
<p>
<code>XSOMParser</code> is the only publicly visible component in this picture. This class also keeps references to vairous other objects that are necessary to parse schemas. This includes an error handler, the root <code>SchemaSet</code> object, an entity resolver, etc.
</p><p>
Whenever the parse method is called, it will create a new NGCCRuntimeEx and configure XMLReader so that a schema file is parsed into this NGCCRuntimeEx instance.
<code>NGCCRuntimeEx</code> derives from <code>NGCCRuntime</code>, which is a class generated by RelaxNGCC. This object will use other RelaxNGCC-generated classes and parse a document and constructs a XSOM object graph appropriately.
</p><p>
When a new XML document is referenced by an import or include statement, a new set of <code>NGCCRuntimeEx</code> is set up to parse that document. One NGCCRuntimeEx can only parse one XML document.
</p>
<h2>Forward references and back-patching</h2>
<p>
Since we use SAX to parse schemas, the referenced schema component is often unavailable when we hit a reference. Because of this, when we see a reference, we create a "delayed" reference that keeps the name of the referenced component.
</p><p>
Note that because of the way XML Schema &lt;redefine> works, all the references by name must be lazily bound even if the component is already defined.
</p><p>
All these "delayed" references are remembered and tracked by XSOMParser. When the client calls the <code>XSOMParser.getResult</code> method, XSOMParser will make sure that they resolve to a schema component correctly.
"Delayed" references are available in the <code>DelayedRef</code> class.
</p>
<h2>RelaxNGCC</h2>
<p>
The actual parser is generated by RelaxNGCC from <code>xsom/src/*.rng</code> files. <code>xmlschema.rng</code> is the entry point and all the other files are referenced from this file. For more information about RelaxNGCC, goto <a href="http://relaxngcc.sourceforge.net/">here</a>. Or just contact me (as I'm one of the developers of RelaxNGCC.)
</p>
</body>
</html>

View File

@ -0,0 +1,58 @@
====
Copyright (C) 2017 Oracle
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.
====
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.
#
# The contents of this file are subject to the terms of either the GNU
# General Public License Version 2 only ("GPL") or the Common Development
# and Distribution License("CDDL") (collectively, the "License"). You
# may not use this file except in compliance with the License. You can
# obtain a copy of the License at
# http://glassfish.java.net/public/CDDL+GPL_1_1.html
# or packager/legal/LICENSE.txt. See the License for the specific
# language governing permissions and limitations under the License.
#
# When distributing the software, include this License Header Notice in each
# file and include the License file at packager/legal/LICENSE.txt.
#
# GPL Classpath Exception:
# Oracle designates this particular file as subject to the "Classpath"
# exception as provided by Oracle in the GPL Version 2 section of the License
# file that accompanied this code.
#
# Modifications:
# If applicable, add the following below the License Header, with the fields
# enclosed by brackets [] replaced by your own identifying information:
# "Portions Copyright [year] [name of copyright owner]"
#
# Contributor(s):
# If you wish your version of this file to be governed by only the CDDL or
# only the GPL Version 2, indicate your decision by adding "[Contributor]
# elects to include this software in this distribution under the [CDDL or GPL
# Version 2] license." If you don't indicate a single choice of license, a
# recipient has the option to distribute your version of this file under
# either the CDDL, the GPL Version 2 or to extend the choice of license to
# its licensees as provided above. However, if you add GPL Version 2 code
# and therefore, elected the GPL Version 2 license, then the option applies
# only if the new code is made subject to such option by the copyright
# holder.
#
- Features that are not used by JAXB are not well tested or not tested at all.

View File

@ -0,0 +1,108 @@
<html>
<head>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
http://glassfish.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<title>Xml Schema Object Model</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<style>
pre {
background-color: rgb(240,240,240);
margin-left: 2em;
margin-right: 2em;
padding: 1em;
}
p {
margin-left: 2em;
}
dl {
margin-left: 2em;
}
</style>
</head>
<body>
<h1 style="text-align:center">XML Schema Object Model</h1>
<div align=right style="font-size:smaller">
By <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke Kawaguchi</a><br>
</div>
<h2>Overview</h2>
<p>
XML Schema Object Model (XSOM) is a Java library that allows applications to easily parse XML Schema documents and inspect information in them. It is expected to be useful for applications that need to take XML Schema as an input.
</p><p>
The library is a straight-forward implement of "schema components" as defined in <a href="http://www.w3.org/TR/xmlschema-1">the XML Schema spec part 1</a>. Refer to this specification of how this object model works. In particular, <a href="http://www.w3.org/TR/xmlschema-1/components.gif">this diagram</a> might be helpful.
</p>
<h2>Documents</h2>
<dl>
<dt><a href="userguide.html">User's Guide</a>
<dd>Learn how to use XSOM
<dt><a href="implementation.html">Implementor's Guide</a>
<dd>Learn the limitations and internals of XSOM
<dt><a href="javadoc/index.html">API Javadoc</a>
<dd>Javadoc of the interfaces
</dl>
<h2>Dependencies</h2>
<p>
XSOM comes in two versions. <code>xsom.jar</code> is built for JDK 5.0, but offers generified version. <code>xsom14.jar</code> is the version that works for earlier versions of JDK.
<p>
Both flavors of <code>xsom.jar</code> depends on <code>relaxngDatatype.jar</code> and JAXP 1.1. Make sure you have at least <code>xsom.jar</code> and <code>relaxngDatatype.jar</code> when you distribute your application that uses XSOM.
</p>
<h2>License</h2>
<p>
XSOM is covered by <a href="license.txt">CDDL</a>, which basically allows you free use and redistribution with your application (but please do check the license for details.) <code>relaxngDatatype.jar</code> is covered by <a href="lib/copying-relaxngDatatype.txt">a BSD-like license</a>. XSOM internally uses an URI class, which is copyrighted by Thai Open Source Center. Its license is <a href="lib/copying-thaiOpensource.txt">here</a>
</p>
<h2>Support</h2>
<p>
Sun does not officially support this product, but Kohsuke Kawaguchi, the developer of this library, will provide support in a best-effort basis at <a href="http://xsom.dev.java.net/">java.net</a>.
</p>
</body>
</html>

View File

@ -0,0 +1,127 @@
<html>
<head>
<title>Retroweaver Overview</title>
<style type="text/css">
<!--body { margin: 0; padding: 0 } -->
</style>
</head>
<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%" background="images/sliver.jpg"><font face="Arial">
<map name="FPMap0">
<area href="index.html" coords="300, 75, 357, 94" shape="rect">
<area href="news.html" coords="352, 75, 425, 94" shape="rect">
<area href="overview.html" coords="425, 75, 520, 94" shape="rect">
<area href="documentation.html" coords="520, 75, 630, 93" shape="rect">
</map>
<img border="0" src="images/seascape.gif" usemap="#FPMap0" width="756" height="133"></font>
</td>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="175" valign="top" background="images/menubg.gif">
<font size="2" face="Arial"><img border="0" src="images/headerbitty.gif" width="175" height="64"></font>
</td>
<td>
<font size="2" face="Arial"><br><b>Overview</b></font>
<ul>
<font size="2" face="Arial">
<li>
What is Retroweaver?
<p> Retroweaver is a tool that enables you to take advantage of the new Java 1.5 language features in your source code, while still retaining compatability with 1.4 (and older) virtual machines. Retroweaver operates by transforming Java class files compiled by a 1.5 compiler into class files which can be run on an older virtual machine.</p>
</li>
<li>
What platforms does the Retroweaver run on?
<p>Any platform Java runs on.</p>
</li>
<li>
Where can I get Retroweaver?
<p>Retroweaver can be downloaded at <a href="http://sf.net/projects/retroweaver">http://sf.net/projects/retroweaver</a></p>
</li>
<li>
How much does Retroweaver cost?
<p>Retroweaver is a free, open-source product. The license for use is BSD-derived. The small print follows:</p>
<pre>
Copyright (c) February 2004, Toby Reyelts
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of Toby Reyelts nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</pre>
</li>
<li>
Who can I ask questions of or give comments or feedback to?
<p>Tools for the Retroweaver user community are hosted at <a href="http://sf.net/projects/retroweaver">SourceForge</a>. If you go there you can browse through or post to the forums, join the mailing list, or even submit bugs or feature requests. On the other hand, you can just chat with the architect and primary author of Retroweaver, <a href="mailto:toby@reyelts.com">Toby Reyelts</a>, directly.</p>
</li>
</ul>
</font>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="right"><A href="http://sourceforge.net"> <IMG src="http://sourceforge.net/sflogo.php?group_id=104240&amp;type=5" width="210" height="62" border="0" alt="SourceForge.net Logo"/></A>&nbsp;&nbsp;</p>
<p>&nbsp;</p>
</tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%" bgcolor="#3999E7">
<p align="center"><font face="Arial"><font size="2">&nbsp;</font><font size="1">Site design by <a href="http://www.pegaweb.com"><b><font color="#000000">Pegasus Web Design Resources</font></b></a></font></font></td>
</tr>
</table>
</center>
</div>
<p>&nbsp;</p>
</body>
</html>

View File

@ -0,0 +1,194 @@
<html>
<head>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
http://glassfish.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<title>XSOM User's Guide</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<style>
pre {
background-color: rgb(240,240,240);
margin-left: 2em;
margin-right: 2em;
padding: 1em;
}
p {
margin-left: 2em;
}
</style>
</head>
<body>
<h1 style="text-align:center">XSOM User's Guide</h1>
<div align=right style="font-size:smaller">
By <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke Kawaguchi</a><br>
</div>
<h1>Parsing a schema</h1>
<p>
Use the <code>com.sun.xml.xsom.parser.XSOMParser</code> class to parse schemas. There are a couple of overloaded versions of the <code>parse</code> method.
</p><p>
<code>XSOMParser</code> works like this; You create a new instance of XSOMParser, set it up, then call the parse method to parse a schema file. When a schema is parsed, all the schemas that are refered from it (&lt;include>and &lt;import>) will also be parsed.
If you have multiple separate schema files that need to be compiled together, just call the parse method multiple times.
</p><p>
Once you parse all the schemas you want, call the getResult method to obtain the <code>XSSchemaSet</code> object, then use that object to obtain information about the schema.
</p>
<pre>
import com.sun.xml.xsom.parser.XSOMParser;
import com.sun.xml.xsom.XSSchemaSet;
XSOMParser parser = new XSOMParser();
parser.setErrorHandler(...);
parser.setEntityResolver(...);
parser.parseSchema( new File("myschema.xsd"));
parser.parseSchema( new File("XHTML.xsd"));
XSSchemaSet sset = parser.getResult();
</pre>
<p>
Now you can access schema information by using this SchemaSet.
</p>
<h2>Parsing from SAX events</h2>
<p>
For more sophisticated uses, you can feed SAX2 events to XSOM. This will be useful when the schema is not present as a stand-alone XML. For example, this can be used to:
</p>
<ul>
<li>parse XML Schema inside another XML, such as WSDL
<li>generate XML on-the-fly and parse it
</ul>
<p>
The following example shows how one can apply a XSLT transformation to produce XML Schema and parse it into XSOM:
</p>
<pre><xmp>
import com.sun.xml.xsom.parser.XSOMParser;
import com.sun.xml.xsom.XSSchemaSet;
XSOMParser parser = new XSOMParser();
parser.setErrorHandler(...);
parser.setEntityResolver(...);
// set up XSLT
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource(new File("wsdl2xsd.xsl"));
ContentHandler xsomHandler = parser.getParserHandler();
// run the transformation and feed the result to XSOM
t.transform(
new StreamSource(new File("test.wsdl")),
new SAXResult(xsomhandler));
XSSchemaSet sset = parser.getResult();
</xmp></pre>
<h2>Error Handling</h2>
<p>
All the error messages will be sent to SAX <code>ErrorHandler</code>, which can be specified through the setErrorHandler method on XSOMParser.
</p>
<h2>Entity Resolution</h2>
<p>
By setting <code>EntityResolver</code> to XSOMParser, you can redirect &lt;xs:include>s and &lt;xs:import>s to different resources. For imports, the namespace URI of the target schema is passed as the public ID, and the absolutized value of the <code>schemaLocation</code> attribute will be passed as the system ID.
</p>
<h2>Parsing Annotations</h2>
<p>
There is a hook in XSOM that allows client applications to parse annotations in schema into an application specific data structure by using <code>AnnotationParser</code>. With this mechanism, the application-specified code can receive SAX events for every annotations found in the document.
</p><p>
<code>AnnotationParser</code> will be responsible for parsing these SAX events into an object, and that object will be attached to the appropriate "owner" schema component by XSOM automatically. The information can be later retrieved through the <code>getAnnotation</code> method.
</p><p>
By default, all the annotations are ignored, but you can easily parse them into a DOM tree or an application-specific data structure.
</p><p>
For details, see <code>com.sun.xml.xsom.impl.parser.AnnotationParser</code> and <code>AnnotationParserFactory</code>. An annotation parser can be attached to XSOMParser through the setAnnotationParser method. There's also a convenient utility class called <tt>DomAnnotationParserFactory</tt> that parses annotations into DOM.
</p>
<h1>Accessing Schema Information</h1>
<p>
The <code>com.sun.xml.xsom</code> package contains all the public interfaces available for client applications. It shouldn't be too hard to understand if you know well about schema components, which are defined in the XML Schema spec.
</p><p>
The interface is modeled after <a href="XML Schema CM API.htm">this document</a> so this might help you understand XSOM.
</p>
<p>
For example, the following code lists all the global element declarations and whether they are abstract or not.
</p>
<pre><xmp>
XSSchemaSet result = /* parse XML Schema */;
// iterate each XSSchema object. XSSchema is a per-namespace schema.
Iterator itr = result.iterateSchema();
while( itr.hasNext() ) {
XSSchema s = (XSSchema)itr.next();
System.out.println("Target namespace: "+s.getTargetNamespace());
Iterator jtr = s.iterateElementDecls();
while( jtr.hasNext() ) {
XSElementDecl e = (XSElementDecl)jtr.next();
System.out.print( e.getName() );
if( e.isAbstract() )
System.out.print(" (abstract)");
System.out.println();
}
}
</xmp></pre>
<h2>Visitor pattern support</h2>
<p>
XSOM comes with a visitor pattern support, which simplifies the development of the client application. XSOM implements two different visitors. One is a visitor that returns void, and the other is a "functor" that returns <code>Object</code>. All the interfaces are available in <code>com.sun.xml.xsom.visitor</code>.
</p><p>
For more about the visitor pattern, see <a href="http://ootips.org/visitor-pattern.html">this summary</a> or read <a href="http://www.amazon.com/exec/obidos/ASIN/0201633612/ootips">this book.</a>
</p>
</body>
</html>