First Commit from Source Code Reply

This commit is contained in:
vincenzofariello
2024-05-09 17:40:24 +02:00
parent 11e3b57c5b
commit 107a016cb9
35225 changed files with 1111346 additions and 1 deletions

View File

@@ -0,0 +1,41 @@
Sample: Any
Author: Steven Traut (straut@bea.com)
Last Updated: June 14, 2005
Versions:
xmlbeans-v1 1.0.3
xmlbeans-v2
-----------------------------------------------------------------------------
This sample illustrates how you can use the XMLBeans API to work with
XML based on schema that features xs:any particles. Unlike other schema
types, xs:any in schema does not result in accessors when you use XMLBeans
to compile schema. Instead, your code must use alternate means to access
and create these parts of the XML. These alternate means include:
- Using XmlCursor instances to "walk" the XML, retrieving and creating
elements.
- Using the selectPath method to retrieve XML via XPath.
- Using the selectChildren method to retrieve elements that are children
by name.
- Using the DOM API to "walk" the node tree, retrieving elements by
name and creating new elements.
When you run this sample, you'll see it print four blocks of information
in the console:
- Results of the Any.buildDocFromScratch method, which builds from scratch the
XML contents of any.xml included with this sample.
- Results of the Any.editExistingDocWithSelectChildren method, which receives
any.xml and replaces one of its elements.
- Results of the Any.editExistingDocWithDOM method, which receives
any.xml and adds an element.
- Results of the Any.editExistingDocWithSelectPath method, which receives
any.xml, promotes one of its elements, and adds a new element.
To try out this sample:
1. Set XMLBEANS_HOME in your environment
2. Ant must be on your PATH
3. To compile the schemas and sample source, run "ant build"
4. To execute the sample, run "ant run"

View File

@@ -0,0 +1,120 @@
<!--
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 name="Any" default="build">
<property environment="env"/>
<path id="Any.path">
<path refid="xmlbeans.path"/>
<fileset dir="build/lib" includes="*.jar"/>
<pathelement path="build/classes"/>
</path>
<target name="init">
<property name="xmlbeans.home" value="${env.XMLBEANS_HOME}"/>
<echo message="xmlbeans.home: ${xmlbeans.home}"/>
<!-- check for xbean.jar from binary distribution -->
<available
property="xmlbeans.lib"
value="${xmlbeans.home}/lib"
file="${xmlbeans.home}/lib/xbean.jar" />
<!-- check for xbean.jar compiled from source -->
<available
property="xmlbeans.lib"
value="${xmlbeans.home}/build/lib"
file="${xmlbeans.home}/build/lib/xbean.jar" />
<fail message="Set XMLBEANS_HOME in your environment."
unless="xmlbeans.lib"/>
<echo message="xmlbeans.lib: ${xmlbeans.lib}"/>
<path id="xmlbeans.path">
<fileset dir="${xmlbeans.lib}" includes="*.jar"/>
</path>
<taskdef name="xmlbean"
classname="org.apache.xmlbeans.impl.tool.XMLBean"
classpathref="xmlbeans.path"/>
</target>
<!-- ========================== clean ==== -->
<target name="clean">
<delete dir="build"/>
</target>
<!-- ========================== build ==== -->
<target name="build" depends="init,schemas.jar,Any.classes">
</target>
<target name="schemas.check">
<uptodate property="schemas.notRequired"
targetfile="build/lib/schemas.jar">
<srcfiles dir="schemas" includes="**/*.xsd"/>
</uptodate>
</target>
<target name="schemas.jar" depends="init,schemas.check"
unless="schemas.notRequired">
<mkdir dir="build/lib"/>
<xmlbean schema="schemas"
destfile="build/lib/schemas.jar"
srcgendir="src"
classpathref="xmlbeans.path"
debug="on"
/>
</target>
<target name="Any.classes" depends="init">
<mkdir dir="build/classes"/>
<javac srcdir="src"
destdir="build/classes"
classpathref="Any.path"
debug="on"
source="1.4"
/>
</target>
<!-- ========================== run ==== -->
<target name="run" depends="init,build">
<echo message="============================== running Any"/>
<java
classname="org.apache.xmlbeans.samples.anytype.Any"
classpathref="Any.path"
fork="true">
<arg line="xml/any.xml"/>
</java>
</target>
<!-- ========================== test ==== -->
<target name="test" depends="init,build">
<echo message="============================== testing Any"/>
<java
classname="org.apache.xmlbeans.samples.anytype.AnyTest"
classpathref="Any.path"
fork="true">
<arg line="xml/any.xml"/>
</java>
</target>
</project>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://xmlbeans.apache.org/samples/any"
targetNamespace="http://xmlbeans.apache.org/samples/any" elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element ref="stringelement"/>
<xs:any processContents="lax"/>
<xs:element name="arrayofany">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="stringelement" type="xs:string"/>
<xs:complexType name="ListOfStrings">
<xs:sequence>
<xs:element ref="stringelement" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
</xs:schema>

View File

@@ -0,0 +1,195 @@
/*
* XML Type: ListOfStrings
* Namespace: http://xmlbeans.apache.org/samples/any
* Java type: org.apache.xmlbeans.samples.any.ListOfStrings
*
* Automatically generated - do not modify.
*/
package org.apache.xmlbeans.samples.any;
/**
* An XML ListOfStrings(@http://xmlbeans.apache.org/samples/any).
*
* This is a complex type.
*/
public interface ListOfStrings extends org.apache.xmlbeans.XmlObject
{
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)schema.system.s6EF7A0057B3F4CED74AE6E05BCAAB5DB.TypeSystemHolder.typeSystem.resolveHandle("listofstringse467type");
/**
* Gets array of all "stringelement" elements
*/
java.lang.String[] getStringelementArray();
/**
* Gets ith "stringelement" element
*/
java.lang.String getStringelementArray(int i);
/**
* Gets (as xml) array of all "stringelement" elements
*/
org.apache.xmlbeans.XmlString[] xgetStringelementArray();
/**
* Gets (as xml) ith "stringelement" element
*/
org.apache.xmlbeans.XmlString xgetStringelementArray(int i);
/**
* Returns number of "stringelement" element
*/
int sizeOfStringelementArray();
/**
* Sets array of all "stringelement" element
*/
void setStringelementArray(java.lang.String[] stringelementArray);
/**
* Sets ith "stringelement" element
*/
void setStringelementArray(int i, java.lang.String stringelement);
/**
* Sets (as xml) array of all "stringelement" element
*/
void xsetStringelementArray(org.apache.xmlbeans.XmlString[] stringelementArray);
/**
* Sets (as xml) ith "stringelement" element
*/
void xsetStringelementArray(int i, org.apache.xmlbeans.XmlString stringelement);
/**
* Inserts the value as the ith "stringelement" element
*/
void insertStringelement(int i, java.lang.String stringelement);
/**
* Appends the value as the last "stringelement" element
*/
void addStringelement(java.lang.String stringelement);
/**
* Inserts and returns a new empty value (as xml) as the ith "stringelement" element
*/
org.apache.xmlbeans.XmlString insertNewStringelement(int i);
/**
* Appends and returns a new empty value (as xml) as the last "stringelement" element
*/
org.apache.xmlbeans.XmlString addNewStringelement();
/**
* Removes the ith "stringelement" element
*/
void removeStringelement(int i);
/**
* Gets the "id" attribute
*/
java.lang.String getId();
/**
* Gets (as xml) the "id" attribute
*/
org.apache.xmlbeans.XmlString xgetId();
/**
* True if has "id" attribute
*/
boolean isSetId();
/**
* Sets the "id" attribute
*/
void setId(java.lang.String id);
/**
* Sets (as xml) the "id" attribute
*/
void xsetId(org.apache.xmlbeans.XmlString id);
/**
* Unsets the "id" attribute
*/
void unsetId();
/**
* A factory class with static methods for creating instances
* of this type.
*/
public static final class Factory
{
public static org.apache.xmlbeans.samples.any.ListOfStrings newInstance() {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings newInstance(org.apache.xmlbeans.XmlOptions options) {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, options ); }
/** @param xmlAsString the string value to parse */
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.lang.String xmlAsString, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, options ); }
/** @param file the file from which to load an xml document */
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.io.File file) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.io.File file, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, options ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, options ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, options ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, options ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(javax.xml.stream.XMLStreamReader sr) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(javax.xml.stream.XMLStreamReader sr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, options ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, null ); }
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, options ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, null ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.samples.any.ListOfStrings parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.apache.xmlbeans.samples.any.ListOfStrings) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, options ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); }
private Factory() { } // No instance of this class allowed
}
}

View File

@@ -0,0 +1,198 @@
/*
* An XML document type.
* Localname: root
* Namespace: http://xmlbeans.apache.org/samples/any
* Java type: org.apache.xmlbeans.samples.any.RootDocument
*
* Automatically generated - do not modify.
*/
package org.apache.xmlbeans.samples.any;
/**
* A document containing one root(@http://xmlbeans.apache.org/samples/any) element.
*
* This is a complex type.
*/
public interface RootDocument extends org.apache.xmlbeans.XmlObject
{
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)schema.system.s6EF7A0057B3F4CED74AE6E05BCAAB5DB.TypeSystemHolder.typeSystem.resolveHandle("root9970doctype");
/**
* Gets the "root" element
*/
org.apache.xmlbeans.samples.any.RootDocument.Root getRoot();
/**
* Sets the "root" element
*/
void setRoot(org.apache.xmlbeans.samples.any.RootDocument.Root root);
/**
* Appends and returns a new empty "root" element
*/
org.apache.xmlbeans.samples.any.RootDocument.Root addNewRoot();
/**
* An XML root(@http://xmlbeans.apache.org/samples/any).
*
* This is a complex type.
*/
public interface Root extends org.apache.xmlbeans.XmlObject
{
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)schema.system.s6EF7A0057B3F4CED74AE6E05BCAAB5DB.TypeSystemHolder.typeSystem.resolveHandle("root2a6eelemtype");
/**
* Gets the "stringelement" element
*/
java.lang.String getStringelement();
/**
* Gets (as xml) the "stringelement" element
*/
org.apache.xmlbeans.XmlString xgetStringelement();
/**
* Sets the "stringelement" element
*/
void setStringelement(java.lang.String stringelement);
/**
* Sets (as xml) the "stringelement" element
*/
void xsetStringelement(org.apache.xmlbeans.XmlString stringelement);
/**
* Gets the "arrayofany" element
*/
org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany getArrayofany();
/**
* Sets the "arrayofany" element
*/
void setArrayofany(org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany arrayofany);
/**
* Appends and returns a new empty "arrayofany" element
*/
org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany addNewArrayofany();
/**
* An XML arrayofany(@http://xmlbeans.apache.org/samples/any).
*
* This is a complex type.
*/
public interface Arrayofany extends org.apache.xmlbeans.XmlObject
{
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)schema.system.s6EF7A0057B3F4CED74AE6E05BCAAB5DB.TypeSystemHolder.typeSystem.resolveHandle("arrayofany08d6elemtype");
/**
* A factory class with static methods for creating instances
* of this type.
*/
public static final class Factory
{
public static org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany newInstance() {
return (org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany newInstance(org.apache.xmlbeans.XmlOptions options) {
return (org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, options ); }
private Factory() { } // No instance of this class allowed
}
}
/**
* A factory class with static methods for creating instances
* of this type.
*/
public static final class Factory
{
public static org.apache.xmlbeans.samples.any.RootDocument.Root newInstance() {
return (org.apache.xmlbeans.samples.any.RootDocument.Root) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument.Root newInstance(org.apache.xmlbeans.XmlOptions options) {
return (org.apache.xmlbeans.samples.any.RootDocument.Root) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, options ); }
private Factory() { } // No instance of this class allowed
}
}
/**
* A factory class with static methods for creating instances
* of this type.
*/
public static final class Factory
{
public static org.apache.xmlbeans.samples.any.RootDocument newInstance() {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument newInstance(org.apache.xmlbeans.XmlOptions options) {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, options ); }
/** @param xmlAsString the string value to parse */
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.lang.String xmlAsString, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, options ); }
/** @param file the file from which to load an xml document */
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.io.File file) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.io.File file, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, options ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, options ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, options ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, options ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(javax.xml.stream.XMLStreamReader sr) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(javax.xml.stream.XMLStreamReader sr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, options ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, null ); }
public static org.apache.xmlbeans.samples.any.RootDocument parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, options ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.samples.any.RootDocument parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, null ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.samples.any.RootDocument parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.apache.xmlbeans.samples.any.RootDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, options ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); }
private Factory() { } // No instance of this class allowed
}
}

View File

@@ -0,0 +1,116 @@
/*
* An XML document type.
* Localname: stringelement
* Namespace: http://xmlbeans.apache.org/samples/any
* Java type: org.apache.xmlbeans.samples.any.StringelementDocument
*
* Automatically generated - do not modify.
*/
package org.apache.xmlbeans.samples.any;
/**
* A document containing one stringelement(@http://xmlbeans.apache.org/samples/any) element.
*
* This is a complex type.
*/
public interface StringelementDocument extends org.apache.xmlbeans.XmlObject
{
public static final org.apache.xmlbeans.SchemaType type = (org.apache.xmlbeans.SchemaType)schema.system.s6EF7A0057B3F4CED74AE6E05BCAAB5DB.TypeSystemHolder.typeSystem.resolveHandle("stringelementc479doctype");
/**
* Gets the "stringelement" element
*/
java.lang.String getStringelement();
/**
* Gets (as xml) the "stringelement" element
*/
org.apache.xmlbeans.XmlString xgetStringelement();
/**
* Sets the "stringelement" element
*/
void setStringelement(java.lang.String stringelement);
/**
* Sets (as xml) the "stringelement" element
*/
void xsetStringelement(org.apache.xmlbeans.XmlString stringelement);
/**
* A factory class with static methods for creating instances
* of this type.
*/
public static final class Factory
{
public static org.apache.xmlbeans.samples.any.StringelementDocument newInstance() {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument newInstance(org.apache.xmlbeans.XmlOptions options) {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance( type, options ); }
/** @param xmlAsString the string value to parse */
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.lang.String xmlAsString, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xmlAsString, type, options ); }
/** @param file the file from which to load an xml document */
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.io.File file) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.io.File file, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( file, type, options ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( u, type, options ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.io.InputStream is) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.io.InputStream is, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( is, type, options ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.io.Reader r) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(java.io.Reader r, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( r, type, options ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(javax.xml.stream.XMLStreamReader sr) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(javax.xml.stream.XMLStreamReader sr, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( sr, type, options ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(org.w3c.dom.Node node) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, null ); }
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(org.w3c.dom.Node node, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( node, type, options ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, null ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.samples.any.StringelementDocument parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return (org.apache.xmlbeans.samples.any.StringelementDocument) org.apache.xmlbeans.XmlBeans.getContextTypeLoader().parse( xis, type, options ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, null ); }
/** @deprecated {@link XMLInputStream} */
public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
return org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newValidatingXMLInputStream( xis, type, options ); }
private Factory() { } // No instance of this class allowed
}
}

View File

@@ -0,0 +1,328 @@
/*
* XML Type: ListOfStrings
* Namespace: http://xmlbeans.apache.org/samples/any
* Java type: org.apache.xmlbeans.samples.any.ListOfStrings
*
* Automatically generated - do not modify.
*/
package org.apache.xmlbeans.samples.any.impl;
/**
* An XML ListOfStrings(@http://xmlbeans.apache.org/samples/any).
*
* This is a complex type.
*/
public class ListOfStringsImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.apache.xmlbeans.samples.any.ListOfStrings
{
public ListOfStringsImpl(org.apache.xmlbeans.SchemaType sType)
{
super(sType);
}
private static final javax.xml.namespace.QName STRINGELEMENT$0 =
new javax.xml.namespace.QName("http://xmlbeans.apache.org/samples/any", "stringelement");
private static final javax.xml.namespace.QName ID$2 =
new javax.xml.namespace.QName("", "id");
/**
* Gets array of all "stringelement" elements
*/
public java.lang.String[] getStringelementArray()
{
synchronized (monitor())
{
check_orphaned();
java.util.List targetList = new java.util.ArrayList();
get_store().find_all_element_users(STRINGELEMENT$0, targetList);
java.lang.String[] result = new java.lang.String[targetList.size()];
for (int i = 0, len = targetList.size() ; i < len ; i++)
result[i] = ((org.apache.xmlbeans.SimpleValue)targetList.get(i)).getStringValue();
return result;
}
}
/**
* Gets ith "stringelement" element
*/
public java.lang.String getStringelementArray(int i)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STRINGELEMENT$0, i);
if (target == null)
{
throw new IndexOutOfBoundsException();
}
return target.getStringValue();
}
}
/**
* Gets (as xml) array of all "stringelement" elements
*/
public org.apache.xmlbeans.XmlString[] xgetStringelementArray()
{
synchronized (monitor())
{
check_orphaned();
java.util.List targetList = new java.util.ArrayList();
get_store().find_all_element_users(STRINGELEMENT$0, targetList);
org.apache.xmlbeans.XmlString[] result = new org.apache.xmlbeans.XmlString[targetList.size()];
targetList.toArray(result);
return result;
}
}
/**
* Gets (as xml) ith "stringelement" element
*/
public org.apache.xmlbeans.XmlString xgetStringelementArray(int i)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STRINGELEMENT$0, i);
if (target == null)
{
throw new IndexOutOfBoundsException();
}
return (org.apache.xmlbeans.XmlString)target;
}
}
/**
* Returns number of "stringelement" element
*/
public int sizeOfStringelementArray()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(STRINGELEMENT$0);
}
}
/**
* Sets array of all "stringelement" element
*/
public void setStringelementArray(java.lang.String[] stringelementArray)
{
synchronized (monitor())
{
check_orphaned();
arraySetterHelper(stringelementArray, STRINGELEMENT$0);
}
}
/**
* Sets ith "stringelement" element
*/
public void setStringelementArray(int i, java.lang.String stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STRINGELEMENT$0, i);
if (target == null)
{
throw new IndexOutOfBoundsException();
}
target.setStringValue(stringelement);
}
}
/**
* Sets (as xml) array of all "stringelement" element
*/
public void xsetStringelementArray(org.apache.xmlbeans.XmlString[]stringelementArray)
{
synchronized (monitor())
{
check_orphaned();
arraySetterHelper(stringelementArray, STRINGELEMENT$0);
}
}
/**
* Sets (as xml) ith "stringelement" element
*/
public void xsetStringelementArray(int i, org.apache.xmlbeans.XmlString stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STRINGELEMENT$0, i);
if (target == null)
{
throw new IndexOutOfBoundsException();
}
target.set(stringelement);
}
}
/**
* Inserts the value as the ith "stringelement" element
*/
public void insertStringelement(int i, java.lang.String stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target =
(org.apache.xmlbeans.SimpleValue)get_store().insert_element_user(STRINGELEMENT$0, i);
target.setStringValue(stringelement);
}
}
/**
* Appends the value as the last "stringelement" element
*/
public void addStringelement(java.lang.String stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(STRINGELEMENT$0);
target.setStringValue(stringelement);
}
}
/**
* Inserts and returns a new empty value (as xml) as the ith "stringelement" element
*/
public org.apache.xmlbeans.XmlString insertNewStringelement(int i)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().insert_element_user(STRINGELEMENT$0, i);
return target;
}
}
/**
* Appends and returns a new empty value (as xml) as the last "stringelement" element
*/
public org.apache.xmlbeans.XmlString addNewStringelement()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().add_element_user(STRINGELEMENT$0);
return target;
}
}
/**
* Removes the ith "stringelement" element
*/
public void removeStringelement(int i)
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(STRINGELEMENT$0, i);
}
}
/**
* Gets the "id" attribute
*/
public java.lang.String getId()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
if (target == null)
{
return null;
}
return target.getStringValue();
}
}
/**
* Gets (as xml) the "id" attribute
*/
public org.apache.xmlbeans.XmlString xgetId()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(ID$2);
return target;
}
}
/**
* True if has "id" attribute
*/
public boolean isSetId()
{
synchronized (monitor())
{
check_orphaned();
return get_store().find_attribute_user(ID$2) != null;
}
}
/**
* Sets the "id" attribute
*/
public void setId(java.lang.String id)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
if (target == null)
{
target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(ID$2);
}
target.setStringValue(id);
}
}
/**
* Sets (as xml) the "id" attribute
*/
public void xsetId(org.apache.xmlbeans.XmlString id)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_attribute_user(ID$2);
if (target == null)
{
target = (org.apache.xmlbeans.XmlString)get_store().add_attribute_user(ID$2);
}
target.set(id);
}
}
/**
* Unsets the "id" attribute
*/
public void unsetId()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_attribute(ID$2);
}
}
}

View File

@@ -0,0 +1,228 @@
/*
* An XML document type.
* Localname: root
* Namespace: http://xmlbeans.apache.org/samples/any
* Java type: org.apache.xmlbeans.samples.any.RootDocument
*
* Automatically generated - do not modify.
*/
package org.apache.xmlbeans.samples.any.impl;
/**
* A document containing one root(@http://xmlbeans.apache.org/samples/any) element.
*
* This is a complex type.
*/
public class RootDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.apache.xmlbeans.samples.any.RootDocument
{
public RootDocumentImpl(org.apache.xmlbeans.SchemaType sType)
{
super(sType);
}
private static final javax.xml.namespace.QName ROOT$0 =
new javax.xml.namespace.QName("http://xmlbeans.apache.org/samples/any", "root");
/**
* Gets the "root" element
*/
public org.apache.xmlbeans.samples.any.RootDocument.Root getRoot()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.samples.any.RootDocument.Root target = null;
target = (org.apache.xmlbeans.samples.any.RootDocument.Root)get_store().find_element_user(ROOT$0, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* Sets the "root" element
*/
public void setRoot(org.apache.xmlbeans.samples.any.RootDocument.Root root)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.samples.any.RootDocument.Root target = null;
target = (org.apache.xmlbeans.samples.any.RootDocument.Root)get_store().find_element_user(ROOT$0, 0);
if (target == null)
{
target = (org.apache.xmlbeans.samples.any.RootDocument.Root)get_store().add_element_user(ROOT$0);
}
target.set(root);
}
}
/**
* Appends and returns a new empty "root" element
*/
public org.apache.xmlbeans.samples.any.RootDocument.Root addNewRoot()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.samples.any.RootDocument.Root target = null;
target = (org.apache.xmlbeans.samples.any.RootDocument.Root)get_store().add_element_user(ROOT$0);
return target;
}
}
/**
* An XML root(@http://xmlbeans.apache.org/samples/any).
*
* This is a complex type.
*/
public static class RootImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.apache.xmlbeans.samples.any.RootDocument.Root
{
public RootImpl(org.apache.xmlbeans.SchemaType sType)
{
super(sType);
}
private static final javax.xml.namespace.QName STRINGELEMENT$0 =
new javax.xml.namespace.QName("http://xmlbeans.apache.org/samples/any", "stringelement");
private static final javax.xml.namespace.QName ARRAYOFANY$2 =
new javax.xml.namespace.QName("http://xmlbeans.apache.org/samples/any", "arrayofany");
/**
* Gets the "stringelement" element
*/
public java.lang.String getStringelement()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STRINGELEMENT$0, 0);
if (target == null)
{
return null;
}
return target.getStringValue();
}
}
/**
* Gets (as xml) the "stringelement" element
*/
public org.apache.xmlbeans.XmlString xgetStringelement()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STRINGELEMENT$0, 0);
return target;
}
}
/**
* Sets the "stringelement" element
*/
public void setStringelement(java.lang.String stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STRINGELEMENT$0, 0);
if (target == null)
{
target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(STRINGELEMENT$0);
}
target.setStringValue(stringelement);
}
}
/**
* Sets (as xml) the "stringelement" element
*/
public void xsetStringelement(org.apache.xmlbeans.XmlString stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STRINGELEMENT$0, 0);
if (target == null)
{
target = (org.apache.xmlbeans.XmlString)get_store().add_element_user(STRINGELEMENT$0);
}
target.set(stringelement);
}
}
/**
* Gets the "arrayofany" element
*/
public org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany getArrayofany()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany target = null;
target = (org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany)get_store().find_element_user(ARRAYOFANY$2, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* Sets the "arrayofany" element
*/
public void setArrayofany(org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany arrayofany)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany target = null;
target = (org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany)get_store().find_element_user(ARRAYOFANY$2, 0);
if (target == null)
{
target = (org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany)get_store().add_element_user(ARRAYOFANY$2);
}
target.set(arrayofany);
}
}
/**
* Appends and returns a new empty "arrayofany" element
*/
public org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany addNewArrayofany()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany target = null;
target = (org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany)get_store().add_element_user(ARRAYOFANY$2);
return target;
}
}
/**
* An XML arrayofany(@http://xmlbeans.apache.org/samples/any).
*
* This is a complex type.
*/
public static class ArrayofanyImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany
{
public ArrayofanyImpl(org.apache.xmlbeans.SchemaType sType)
{
super(sType);
}
}
}
}

View File

@@ -0,0 +1,94 @@
/*
* An XML document type.
* Localname: stringelement
* Namespace: http://xmlbeans.apache.org/samples/any
* Java type: org.apache.xmlbeans.samples.any.StringelementDocument
*
* Automatically generated - do not modify.
*/
package org.apache.xmlbeans.samples.any.impl;
/**
* A document containing one stringelement(@http://xmlbeans.apache.org/samples/any) element.
*
* This is a complex type.
*/
public class StringelementDocumentImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements org.apache.xmlbeans.samples.any.StringelementDocument
{
public StringelementDocumentImpl(org.apache.xmlbeans.SchemaType sType)
{
super(sType);
}
private static final javax.xml.namespace.QName STRINGELEMENT$0 =
new javax.xml.namespace.QName("http://xmlbeans.apache.org/samples/any", "stringelement");
/**
* Gets the "stringelement" element
*/
public java.lang.String getStringelement()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STRINGELEMENT$0, 0);
if (target == null)
{
return null;
}
return target.getStringValue();
}
}
/**
* Gets (as xml) the "stringelement" element
*/
public org.apache.xmlbeans.XmlString xgetStringelement()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STRINGELEMENT$0, 0);
return target;
}
}
/**
* Sets the "stringelement" element
*/
public void setStringelement(java.lang.String stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(STRINGELEMENT$0, 0);
if (target == null)
{
target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(STRINGELEMENT$0);
}
target.setStringValue(stringelement);
}
}
/**
* Sets (as xml) the "stringelement" element
*/
public void xsetStringelement(org.apache.xmlbeans.XmlString stringelement)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(STRINGELEMENT$0, 0);
if (target == null)
{
target = (org.apache.xmlbeans.XmlString)get_store().add_element_user(STRINGELEMENT$0);
}
target.set(stringelement);
}
}
}

View File

@@ -0,0 +1,457 @@
/* 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.
*/
package org.apache.xmlbeans.samples.anytype;
import org.apache.xmlbeans.*;
import org.apache.xmlbeans.samples.any.ListOfStrings;
import org.apache.xmlbeans.samples.any.RootDocument;
import org.apache.xmlbeans.samples.any.StringelementDocument;
import org.apache.xmlbeans.samples.any.RootDocument.Root.Arrayofany;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import javax.xml.namespace.QName;
/**
* A sample that illustrates various ways to manipulate XML whose
* schema defines elements as type xs:any. Unlike its treatment of
* other schema types, XMLBeans does not generate accessors for the
* xs:any particle when compiling schema. Instead, your code
* handles instances of this type through any of several alternative
* means, including XPath queries, the selectChildren method,
* XmlCursor instances and the DOM API. This samples illustrates
* these alternative approaches.
*/
public class Any
{
private static final String m_namespaceUri = "http://xmlbeans.apache.org/samples/any";
/**
* Receives <root> XML instance, executing methods that
* edit the received instance or create a new one.
*
* @param args An array in which the first item is a
* path to the XML instance file.
*/
public static void main(String[] args)
{
Any thisSample = new Any();
System.out.println("Running Any.buildDocFromScratch\n");
thisSample.buildDocFromScratch();
RootDocument rootDoc = (RootDocument)thisSample.parseXml(args[0]);
System.out.println("Running Any.editExistingDocWithSelectChildren\n");
thisSample.editExistingDocWithSelectChildren(rootDoc);
System.out.println("Running Any.editExistingDocWithDOM\n");
thisSample.editExistingDocWithDOM(rootDoc);
System.out.println("Running Any.editExistingDocWithSelectPath\n");
thisSample.editExistingDocWithSelectPath(rootDoc);
}
/**
* Creates a new <root> document from scratch.
*
* This method illustrates how you can use XmlCursor instances
* to build XML that is defined in schema as xs:any.
*
* @return <code>true</code> if the new document is valid;
* otherwise, <code>false</code>.
*/
public boolean buildDocFromScratch()
{
// Start by creating a <root> element that will contain
// the children built by this method.
RootDocument rootDoc = RootDocument.Factory.newInstance();
RootDocument.Root root = rootDoc.addNewRoot();
// Add the first element, <stringelement>.
root.setStringelement("some text");
// Create an XmlObject in which to build the second
// element in the sequence, <anyfoo>. Here, the
// XmlObject instance is simply a kind of incubator
// for the XML. Later the XML will be moved into the
// document this code is building.
XmlObject anyFoo = XmlObject.Factory.newInstance();
// Add a cursor to do the work of building the XML.
XmlCursor childCursor = anyFoo.newCursor();
childCursor.toNextToken();
// Add the element in the schema's namespace, then add
// element content.
childCursor.beginElement(new QName(m_namespaceUri, "anyfoo"));
childCursor.insertChars("some text");
// Move the cursor back to the new element's top, where
// it can grab the element's XML.
childCursor.toStartDoc();
childCursor.toNextToken();
// Move the XML into the <root> document by moving it
// from a position at one cursor to a position at
// another.
XmlCursor rootCursor = root.newCursor();
rootCursor.toEndToken();
childCursor.moveXml(rootCursor);
// Add the fourth element, <arrayofany>, by building it
// elsewhere, then moving the new XML into place under
// <root>.
Arrayofany arrayOfAny = root.addNewArrayofany();
if (buildArrayOfAny(arrayOfAny) == null)
{
return false;
}
childCursor.dispose();
rootCursor.dispose();
// Print and validate the result.
System.out.println("Output: The <root> document built from scratch.\n");
System.out.println(rootDoc + "\n");
return validateXml(rootDoc);
}
/**
* Replaces the <anyfoo> element with an <anybar> element in the
* incoming XML.
*
* This method illustrates how you can use the XmlCursor.selectChildren
* method to retrieve child elements whose type is defined as
* xs:any in schema.
*
* @param rootDoc An instance of the <root> XML document.
* @return <code>true</code> if the editing XML is valid;
* otherwise, <code>false</code>.
*/
public boolean editExistingDocWithSelectChildren(RootDocument rootDoc)
{
RootDocument.Root root = rootDoc.getRoot();
// Select the <anyfoo> children of <root>.
XmlObject[] stringElements =
root.selectChildren(new QName(m_namespaceUri, "anyfoo"));
// If the element is there, replace it with another element.
if (stringElements.length > 0)
{
XmlCursor editCursor = stringElements[0].newCursor();
editCursor.removeXml();
editCursor.beginElement(new QName(m_namespaceUri, "anybar"));
editCursor.insertChars("some other text");
editCursor.dispose();
}
System.out.println("Output: The <anyfoo> element has been replaced\n" +
"by an <anybar> element.\n");
System.out.println(rootDoc + "\n");
return validateXml(rootDoc);
}
/**
* Adds a new <bar> element between the first and second
* children of the <arrayofany> element.
*
* This method illustrates how you can use DOM methods to
* retrieve and edit elements whose type is defined as
* xs:any in schema.
*
* @param rootDoc An instance of the <root> XML document.
* @return <code>true</code> if the editing XML is valid;
* otherwise, <code>false</code>.
*/
public boolean editExistingDocWithDOM(RootDocument rootDoc)
{
RootDocument.Root root = rootDoc.getRoot();
// Get the DOM nodes for the <arrayofany> element's children.
Node arrayOfAnyNode = root.getArrayofany().getDomNode();
// You don't have get* accessors for any of the <arrayofany>
// element's children, so use DOM to identify the first
// and second elements while looping through the child list.
NodeList childList = arrayOfAnyNode.getChildNodes();
Element firstElementChild = null;
Element secondElementChild = null;
// Find the first child element and make sure it's
// <stringelement>.
for (int i = 0; i < childList.getLength(); i++)
{
Node node = childList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE)
{
if (node.getLocalName().equals("stringelement"))
{
firstElementChild = (Element)node;
break;
}
}
}
if (firstElementChild == null) {return false;}
// Find the second child element and make sure it's
// <someelement>.
Node node = firstElementChild.getNextSibling();
do {
if (node.getNodeType() == Node.ELEMENT_NODE)
{
if (node.getLocalName().equals("someelement"))
{
secondElementChild = (Element)node;
break;
}
}
node = node.getNextSibling();
} while (node != null);
if (secondElementChild == null) {return false;}
// Create and insert a new <bar> element.
Element fooElement =
secondElementChild.getOwnerDocument().createElementNS("http://openuri.org","bar");
Node valueNode =
fooElement.getOwnerDocument().createTextNode("some text");
fooElement.appendChild(valueNode);
arrayOfAnyNode.insertBefore(fooElement, secondElementChild);
System.out.println("Output: <arrayofany> has a new <bar> child element.\n");
System.out.println(rootDoc + "\n");
return validateXml(rootDoc);
}
/**
* Edits incoming <root> XML to make the following changes: replace
* <somelement> with its <stringlist> child; add a new <foo>
* element as the second child of <arrayofany>.
*
* This method illustrates how you can use the selectPath method
* to find an element defined as xs:any in schema, then use
* XmlCursor instances to edit the XML.
*
* @param rootDoc An instance of the <root> XML document.
* @return <code>true</code> if the editing XML is valid;
* otherwise, <code>false</code>.
*/
public boolean editExistingDocWithSelectPath(RootDocument rootDoc)
{
String namespaceDecl = "declare namespace any='" +
m_namespaceUri + "'; ";
XmlCursor selectionCursor = rootDoc.getRoot().getArrayofany().newCursor();
// Save the cursor's position for later, then use XPath
// and cursor movement to position the cursor at
// the <stringlist> element.
selectionCursor.push();
selectionCursor.selectPath(namespaceDecl +
"$this//any:someelement/any:stringlist");
selectionCursor.toNextSelection();
// Create a new cursor and move it to the selection
// cursor's <someelement> parent. Moving the
// <stringlist> element to this position, displacing
// the <someelement> downward, then removing the
// <someelement> XML effectively replaces <someelement>
// with <stringlist>.
XmlCursor editCursor = selectionCursor.newCursor();
editCursor.toParent();
selectionCursor.moveXml(editCursor);
editCursor.removeXml();
editCursor.dispose();
// Return the cursor to the <arrayofany> element so you
// can do more editing. Then move the cursor to the second
// child and insert a new element as second child.
selectionCursor.pop();
selectionCursor.toFirstChild();
selectionCursor.toNextSibling();
selectionCursor.beginElement("foo", "http://openuri.org");
selectionCursor.insertChars("some text");
selectionCursor.dispose();
System.out.println("Output: <stringlist> has been promoted to replace \n" +
"<someelement>, and there's a new <foo> element.\n");
System.out.println(rootDoc + "\n");
return validateXml(rootDoc);
}
/**
* Like the code in the buildDocFromScratch method, this code
* uses the XmlCursor to build XML piece by piece, building
* out the Arrayofany instance it receives.
*
* @return A valid <arrayofany> element bound to an
* Arrrayofany instance.
*/
private Arrayofany buildArrayOfAny(Arrayofany arrayOfAny)
{
// Create a simple <stringelement> and move it into place
// under <arrayofany>.
StringelementDocument stringElementDoc =
StringelementDocument.Factory.newInstance();
stringElementDoc.setStringelement("some text");
XmlCursor childCursor = stringElementDoc.newCursor();
childCursor.toFirstContentToken();
// Add a cursor to mark the position at which the new child
// XML will be moved.
XmlCursor arrayCursor = arrayOfAny.newCursor();
arrayCursor.toNextToken();
childCursor.moveXml(arrayCursor);
childCursor.dispose();
// Create a <someelement> that contains a <stringlist>
// child element, then get the XmlObject representing the new
// <stringlist>. Note that the XmlCursor.beginElement method
// leaves the cursor between START and END tokens -- where
// content can be placed.
arrayCursor.beginElement("someelement", m_namespaceUri);
arrayCursor.beginElement("stringlist", m_namespaceUri);
arrayCursor.toPrevToken();
XmlObject stringList = arrayCursor.getObject();
// The cursor's no longer needed.
arrayCursor.dispose();
// Create the <stringlist> element's value and set it.
ListOfStrings stringListValue = buildListOfStrings();
if (stringListValue == null)
{
return null;
}
stringList.set(stringListValue);
// Validate the new XML.
if (!validateXml(arrayOfAny))
{
return null;
}
return arrayOfAny;
}
/**
* Creates an instance of the ListOfStrings complex type defined
* in the schema. The instance returned by this method can be
* inserted using either a set* operation or a cursor, as in
* {@link #buildArrayOfAny()}.
*
* @return A valid instance of ListOfStrings.
*/
private ListOfStrings buildListOfStrings()
{
// Create an instance of the ListOfStrings complex type.
ListOfStrings stringList = ListOfStrings.Factory.newInstance();
stringList.setId("001");
// Add two children for the instance's root.
XmlString stringElement = stringList.addNewStringelement();
stringElement.setStringValue("string1");
stringElement = stringList.addNewStringelement();
stringElement.setStringValue("string2");
// Validate the new XML.
if (!validateXml(stringList))
{
return null;
}
return stringList;
}
/**
* <p>Validates the XML, printing error messages when the XML is invalid. Note
* that this method will properly validate any instance of a compiled schema
* type because all of these types extend XmlObject.</p>
*
* <p>Note that in actual practice, you'll probably want to use an assertion
* when validating if you want to ensure that your code doesn't pass along
* invalid XML. This sample prints the generated XML whether or not it's
* valid so that you can see the result in both cases.</p>
*
* @param xml The XML to validate.
* @return <code>true</code> if the XML is valid; otherwise, <code>false</code>
*/
public static boolean validateXml(XmlObject xml)
{
boolean isXmlValid = false;
// A collection instance to hold validation error messages.
ArrayList validationMessages = new ArrayList();
// Validate the XML, collecting messages.
isXmlValid = xml.validate(
new XmlOptions().setErrorListener(validationMessages));
// If the XML isn't valid, print the messages.
if (!isXmlValid)
{
printErrors(validationMessages);
}
return isXmlValid;
}
/**
* Receives the collection containing errors found during
* validation and print the errors to the console.
*
* @param validationErrors The validation errors.
*/
public static void printErrors(ArrayList validationErrors)
{
Iterator iter = validationErrors.iterator();
while (iter.hasNext())
{
System.out.println(">> " + iter.next() + "\n");
}
}
/**
* <p>Creates a File from the XML path provided in main arguments, then
* parses the file's contents into a type generated from schema.</p>
* <p/>
* <p>Note that this work might have been done in main. Isolating it here
* makes the code separately available from outside this class.</p>
*
* @param xmlFilePath A path to XML based on the schema in inventory.xsd.
* @return An instance of a generated schema type that contains the parsed
* XML.
*/
public XmlObject parseXml(String xmlFilePath)
{
File xmlFile = new File(xmlFilePath);
XmlObject xml = null;
try
{
xml = XmlObject.Factory.parse(xmlFile);
} catch (XmlException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
return xml;
}
}

View File

@@ -0,0 +1,45 @@
/* 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.
*/
package org.apache.xmlbeans.samples.anytype;
import org.apache.xmlbeans.samples.any.RootDocument;
/**
* A class with which to test the Any sample.
*/
public class AnyTest
{
/**
* Tests the Any sample.
*/
public static void main(String[] args)
{
Any sample = new Any();
boolean newDocIsValid = sample.buildDocFromScratch();
// assert !newDocIsValid;
RootDocument rootDoc = (RootDocument)sample.parseXml(args[0]);
boolean domEditsAreValid = sample.editExistingDocWithDOM(rootDoc);
// assert !domEditsAreValid;
boolean selectPathEditsAreValid = sample.editExistingDocWithSelectPath(rootDoc);
// assert !selectPathEditsAreValid;
boolean selectChildrenEditsAreValid = sample.editExistingDocWithSelectChildren(rootDoc);
// assert !selectChildrenEditsAreValid;
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--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.-->
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlbeans.apache.org/samples/any">
<stringelement>some text</stringelement>
<anyfoo>some text</anyfoo>
<arrayofany>
<stringelement>some text</stringelement>
<someelement>
<stringlist id="001">
<stringelement>string1</stringelement>
<stringelement>string2</stringelement>
</stringlist>
</someelement>
</arrayofany>
</root>