feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSAnnotation;
import org.xml.sax.Locator;
import org.xml.sax.helpers.LocatorImpl;
public class AnnotationImpl implements XSAnnotation
{
private Object annotation;
public Object getAnnotation() { return annotation; }
public Object setAnnotation(Object o) {
Object r = this.annotation;
this.annotation = o;
return r;
}
private final Locator locator;
public Locator getLocator() { return locator; }
public AnnotationImpl( Object o, Locator _loc ) {
this.annotation = o;
this.locator = _loc;
}
public AnnotationImpl() {
locator = NULL_LOCATION;
}
private static class LocatorImplUnmodifiable extends LocatorImpl {
@Override
public void setColumnNumber(int columnNumber) {
return;
}
@Override
public void setPublicId(String publicId) {
return;
}
@Override
public void setSystemId(String systemId) {
return;
}
@Override
public void setLineNumber(int lineNumber) {
return;
}
};
private static final LocatorImplUnmodifiable NULL_LOCATION = new LocatorImplUnmodifiable();
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.impl.parser.DelayedRef;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import java.util.Iterator;
public class AttGroupDeclImpl extends AttributesHolder implements XSAttGroupDecl
{
public AttGroupDeclImpl( SchemaDocumentImpl _parent, AnnotationImpl _annon,
Locator _loc, ForeignAttributesImpl _fa, String _name, WildcardImpl _wildcard ) {
this(_parent,_annon,_loc,_fa,_name);
setWildcard(_wildcard);
}
public AttGroupDeclImpl( SchemaDocumentImpl _parent, AnnotationImpl _annon,
Locator _loc, ForeignAttributesImpl _fa, String _name ) {
super(_parent,_annon,_loc,_fa,_name,false);
}
private WildcardImpl wildcard;
public void setWildcard( WildcardImpl wc ) { wildcard=wc; }
public XSWildcard getAttributeWildcard() { return wildcard; }
public XSAttributeUse getAttributeUse( String nsURI, String localName ) {
UName name = new UName(nsURI,localName);
XSAttributeUse o=null;
Iterator itr = iterateAttGroups();
while(itr.hasNext() && o==null)
o = ((XSAttGroupDecl)itr.next()).getAttributeUse(nsURI,localName);
if(o==null) o = attributes.get(name);
return o;
}
public void redefine( AttGroupDeclImpl ag ) {
for (Iterator itr = attGroups.iterator(); itr.hasNext();) {
DelayedRef.AttGroup r = (DelayedRef.AttGroup) itr.next();
r.redefine(ag);
}
}
public void visit( XSVisitor visitor ) {
visitor.attGroupDecl(this);
}
public Object apply( XSFunction function ) {
return function.attGroupDecl(this);
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XmlString;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
public class AttributeDeclImpl extends DeclarationImpl implements XSAttributeDecl, Ref.Attribute
{
public AttributeDeclImpl( SchemaDocumentImpl owner,
String _targetNamespace, String _name,
AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa, boolean _anonymous,
XmlString _defValue, XmlString _fixedValue,
Ref.SimpleType _type ) {
super(owner,_annon,_loc,_fa,_targetNamespace,_name,_anonymous);
if(_name==null) // assertion failed.
throw new IllegalArgumentException();
this.defaultValue = _defValue;
this.fixedValue = _fixedValue;
this.type = _type;
}
private final Ref.SimpleType type;
public XSSimpleType getType() { return type.getType(); }
private final XmlString defaultValue;
public XmlString getDefaultValue() { return defaultValue; }
private final XmlString fixedValue;
public XmlString getFixedValue() { return fixedValue; }
public void visit( XSVisitor visitor ) {
visitor.attributeDecl(this);
}
public Object apply( XSFunction function ) {
return function.attributeDecl(this);
}
// Ref.Attribute implementation
public XSAttributeDecl getAttribute() { return this; }
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.XmlString;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
public class AttributeUseImpl extends ComponentImpl implements XSAttributeUse
{
public AttributeUseImpl( SchemaDocumentImpl owner, AnnotationImpl ann, Locator loc, ForeignAttributesImpl fa, Ref.Attribute _decl,
XmlString def, XmlString fixed, boolean req ) {
super(owner,ann,loc,fa);
this.att = _decl;
this.defaultValue = def;
this.fixedValue = fixed;
this.required = req;
}
private final Ref.Attribute att;
public XSAttributeDecl getDecl() { return att.getAttribute(); }
private final XmlString defaultValue;
public XmlString getDefaultValue() {
if( defaultValue!=null ) return defaultValue;
else return getDecl().getDefaultValue();
}
private final XmlString fixedValue;
public XmlString getFixedValue() {
if( fixedValue!=null ) return fixedValue;
else return getDecl().getFixedValue();
}
private final boolean required;
public boolean isRequired() { return required; }
public Object apply( XSFunction f ) {
return f.attributeUse(this);
}
public void visit( XSVisitor v ) {
v.attributeUse(this);
}
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.impl.scd.Iterators;
import com.sun.xml.internal.xsom.impl.Ref.AttGroup;
import org.xml.sax.Locator;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.LinkedHashMap;
public abstract class AttributesHolder extends DeclarationImpl {
protected AttributesHolder( SchemaDocumentImpl _parent, AnnotationImpl _annon,
Locator loc, ForeignAttributesImpl _fa, String _name, boolean _anonymous ) {
super(_parent,_annon,loc,_fa,_parent.getTargetNamespace(),_name,_anonymous);
}
/** set the local wildcard. */
public abstract void setWildcard(WildcardImpl wc);
/**
* Local attribute use.
* Use linked hash map to guarantee the iteration order, and make it close to
* what was in the schema document.
*/
protected final Map<UName,AttributeUseImpl> attributes = new LinkedHashMap<UName,AttributeUseImpl>();
public void addAttributeUse( UName name, AttributeUseImpl a ) {
attributes.put( name, a );
}
/** prohibited attributes. */
protected final Set<UName> prohibitedAtts = new HashSet<UName>();
public void addProhibitedAttribute( UName name ) {
prohibitedAtts.add(name);
}
/**
* Returns the attribute uses by looking at attribute groups and etc.
* Searching for the base type is done in {@link ComplexTypeImpl}.
*/
public Collection<XSAttributeUse> getAttributeUses() {
// TODO: this is fairly inefficient
List<XSAttributeUse> v = new ArrayList<XSAttributeUse>();
v.addAll(attributes.values());
for( XSAttGroupDecl agd : getAttGroups() )
v.addAll(agd.getAttributeUses());
return v;
}
public Iterator<XSAttributeUse> iterateAttributeUses() {
return getAttributeUses().iterator();
}
public XSAttributeUse getDeclaredAttributeUse( String nsURI, String localName ) {
return attributes.get(new UName(nsURI,localName));
}
public Iterator<AttributeUseImpl> iterateDeclaredAttributeUses() {
return attributes.values().iterator();
}
public Collection<AttributeUseImpl> getDeclaredAttributeUses() {
return attributes.values();
}
/** {@link Ref.AttGroup}s that are directly refered from this. */
protected final Set<Ref.AttGroup> attGroups = new HashSet<Ref.AttGroup>();
public void addAttGroup( Ref.AttGroup a ) { attGroups.add(a); }
// Iterates all AttGroups which are directly referenced from this component
// this does not iterate att groups referenced from the base type
public Iterator<XSAttGroupDecl> iterateAttGroups() {
return new Iterators.Adapter<XSAttGroupDecl,Ref.AttGroup>(attGroups.iterator()) {
protected XSAttGroupDecl filter(AttGroup u) {
return u.get();
}
};
}
public Set<XSAttGroupDecl> getAttGroups() {
return new AbstractSet<XSAttGroupDecl>() {
public Iterator<XSAttGroupDecl> iterator() {
return iterateAttGroups();
}
public int size() {
return attGroups.size();
}
};
}
}

View File

@@ -0,0 +1,299 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSSchema;
import com.sun.xml.internal.xsom.XSSchemaSet;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.impl.parser.DelayedRef;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.impl.scd.Iterators;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Locator;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class ComplexTypeImpl extends AttributesHolder implements XSComplexType, Ref.ComplexType
{
public ComplexTypeImpl( SchemaDocumentImpl _parent,
AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
String _name, boolean _anonymous,
boolean _abstract, int _derivationMethod,
Ref.Type _base, int _final, int _block, boolean _mixed ) {
super(_parent,_annon,_loc,_fa,_name,_anonymous);
if(_base==null)
throw new IllegalArgumentException();
this._abstract = _abstract;
this.derivationMethod = _derivationMethod;
this.baseType = _base;
this.finalValue = _final;
this.blockValue = _block;
this.mixed = _mixed;
}
public XSComplexType asComplexType(){ return this; }
public boolean isDerivedFrom(XSType t) {
XSType x = this;
while(true) {
if(t==x)
return true;
XSType s = x.getBaseType();
if(s==x)
return false;
x = s;
}
}
public XSSimpleType asSimpleType() { return null; }
public final boolean isSimpleType() { return false; }
public final boolean isComplexType(){ return true; }
private int derivationMethod;
public int getDerivationMethod() { return derivationMethod; }
private Ref.Type baseType;
public XSType getBaseType() { return baseType.getType(); }
/**
* Called when this complex type redefines the specified complex type.
*/
public void redefine( ComplexTypeImpl ct ) {
if( baseType instanceof DelayedRef )
((DelayedRef)baseType).redefine(ct);
else
this.baseType = ct;
ct.redefinedBy = this;
redefiningCount = (short)(ct.redefiningCount+1);
}
/**
* Number of times this component redefines other components.
*/
private short redefiningCount = 0;
private ComplexTypeImpl redefinedBy = null;
public XSComplexType getRedefinedBy() {
return redefinedBy;
}
public int getRedefinedCount() {
int i=0;
for( ComplexTypeImpl ct=this.redefinedBy; ct!=null; ct=ct.redefinedBy)
i++;
return i;
}
private XSElementDecl scope;
public XSElementDecl getScope() { return scope; }
public void setScope( XSElementDecl _scope ) { this.scope=_scope; }
private final boolean _abstract;
public boolean isAbstract() { return _abstract; }
private WildcardImpl localAttWildcard;
/**
* Set the local attribute wildcard.
*/
public void setWildcard( WildcardImpl wc ) {
this.localAttWildcard = wc;
}
public XSWildcard getAttributeWildcard() {
WildcardImpl complete = localAttWildcard;
Iterator itr = iterateAttGroups();
while( itr.hasNext() ) {
WildcardImpl w = (WildcardImpl)((XSAttGroupDecl)itr.next()).getAttributeWildcard();
if(w==null) continue;
if(complete==null)
complete = w;
else
// TODO: the spec says it's intersection,
// but I think it has to be union.
complete = complete.union(ownerDocument,w);
}
if( getDerivationMethod()==RESTRICTION ) return complete;
WildcardImpl base=null;
XSType baseType = getBaseType();
if(baseType.asComplexType()!=null)
base = (WildcardImpl)baseType.asComplexType().getAttributeWildcard();
if(complete==null) return base;
if(base==null) return complete;
return complete.union(ownerDocument,base);
}
private final int finalValue;
public boolean isFinal( int derivationMethod ) {
return (finalValue&derivationMethod)!=0;
}
private final int blockValue;
public boolean isSubstitutionProhibited( int method ) {
return (blockValue&method)!=0;
}
private Ref.ContentType contentType;
public void setContentType( Ref.ContentType v ) { contentType = v; }
public XSContentType getContentType() { return contentType.getContentType(); }
private XSContentType explicitContent;
public void setExplicitContent( XSContentType v ) {
this.explicitContent = v;
}
public XSContentType getExplicitContent() { return explicitContent; }
private final boolean mixed;
public boolean isMixed() { return mixed; }
public XSAttributeUse getAttributeUse( String nsURI, String localName ) {
UName name = new UName(nsURI,localName);
if(prohibitedAtts.contains(name)) return null;
XSAttributeUse o = attributes.get(name);
if(o==null) {
Iterator itr = iterateAttGroups();
while(itr.hasNext() && o==null)
o = ((XSAttGroupDecl)itr.next()).getAttributeUse(nsURI,localName);
}
if(o==null) {
XSType base = getBaseType();
if(base.asComplexType()!=null)
o = base.asComplexType().getAttributeUse(nsURI,localName);
}
return o;
}
public Iterator<XSAttributeUse> iterateAttributeUses() {
XSComplexType baseType = getBaseType().asComplexType();
if( baseType==null ) return super.iterateAttributeUses();
return new Iterators.Union<XSAttributeUse>(
new Iterators.Filter<XSAttributeUse>(baseType.iterateAttributeUses()) {
protected boolean matches(XSAttributeUse value) {
XSAttributeDecl u = value.getDecl();
UName n = new UName(u.getTargetNamespace(),u.getName());
return !prohibitedAtts.contains(n);
}
},
super.iterateAttributeUses() );
}
public Collection<XSAttributeUse> getAttributeUses() {
XSComplexType baseType = getBaseType().asComplexType();
if( baseType==null ) return super.getAttributeUses();
// TODO: this is fairly inefficient
Map<UName,XSAttributeUse> uses = new HashMap<UName, XSAttributeUse>();
for( XSAttributeUse a : baseType.getAttributeUses())
uses.put(new UName(a.getDecl()),a);
uses.keySet().removeAll(prohibitedAtts);
for( XSAttributeUse a : super.getAttributeUses())
uses.put(new UName(a.getDecl()),a);
return uses.values();
}
public XSType[] listSubstitutables() {
return Util.listSubstitutables(this);
}
public void visit( XSVisitor visitor ) {
visitor.complexType(this);
}
public <T> T apply( XSFunction<T> function ) {
return function.complexType(this);
}
// Ref.ComplexType implementation
public XSComplexType getType() { return this; }
public List<XSComplexType> getSubtypes() {
ArrayList subtypeList = new ArrayList();
Iterator<XSComplexType> cTypes = getRoot().iterateComplexTypes();
while (cTypes.hasNext()) {
XSComplexType cType= cTypes.next();
XSType base = cType.getBaseType();
if ((base != null) && (base.equals(this))) {
subtypeList.add(cType);
}
}
return subtypeList;
}
public List<XSElementDecl> getElementDecls() {
ArrayList declList = new ArrayList();
XSSchemaSet schemaSet = getRoot();
for (XSSchema sch : schemaSet.getSchemas()) {
for (XSElementDecl decl : sch.getElementDecls().values()) {
if (decl.getType().equals(this)) {
declList.add(decl);
}
}
}
return declList;
}
}

View File

@@ -0,0 +1,143 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.SCD;
import com.sun.xml.internal.xsom.XSAnnotation;
import com.sun.xml.internal.xsom.XSComponent;
import com.sun.xml.internal.xsom.XSSchemaSet;
import com.sun.xml.internal.xsom.util.ComponentNameFunction;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.parser.SchemaDocument;
import org.xml.sax.Locator;
import javax.xml.namespace.NamespaceContext;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public abstract class ComponentImpl implements XSComponent
{
protected ComponentImpl( SchemaDocumentImpl _owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa ) {
this.ownerDocument = _owner;
this.annotation = _annon;
this.locator = _loc;
this.foreignAttributes = fa;
}
protected final SchemaDocumentImpl ownerDocument;
public SchemaImpl getOwnerSchema() {
if(ownerDocument==null)
return null;
else
return ownerDocument.getSchema();
}
public XSSchemaSet getRoot() {
if(ownerDocument==null)
return null;
else
return getOwnerSchema().getRoot();
}
public SchemaDocument getSourceDocument() {
return ownerDocument;
}
private AnnotationImpl annotation;
public final XSAnnotation getAnnotation() { return annotation; }
public XSAnnotation getAnnotation(boolean createIfNotExist) {
if(createIfNotExist && annotation==null) {
annotation = new AnnotationImpl();
}
return annotation;
}
private final Locator locator;
public final Locator getLocator() { return locator; }
/**
* Either {@link ForeignAttributesImpl} or {@link List}.
*
* Initially it's {@link ForeignAttributesImpl}, but it's lazily turned into
* a list when necessary.
*/
private Object foreignAttributes;
public List<ForeignAttributesImpl> getForeignAttributes() {
Object t = foreignAttributes;
if(t==null)
return Collections.EMPTY_LIST;
if(t instanceof List)
return (List)t;
t = foreignAttributes = convertToList((ForeignAttributesImpl)t);
return (List)t;
}
public String getForeignAttribute(String nsUri, String localName) {
for( ForeignAttributesImpl fa : getForeignAttributes() ) {
String v = fa.getValue(nsUri,localName);
if(v!=null) return v;
}
return null;
}
private List<ForeignAttributesImpl> convertToList(ForeignAttributesImpl fa) {
List<ForeignAttributesImpl> lst = new ArrayList<ForeignAttributesImpl>();
while(fa!=null) {
lst.add(fa);
fa = fa.next;
}
return Collections.unmodifiableList(lst);
}
public Collection<XSComponent> select(String scd, NamespaceContext nsContext) {
try {
return SCD.create(scd,nsContext).select(this);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
public XSComponent selectSingle(String scd, NamespaceContext nsContext) {
try {
return SCD.create(scd,nsContext).selectSingle(this);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
@Override
public String toString() {
return apply(new ComponentNameFunction());
}
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
public class Const
{
/** Namespace URI of XML Schema. */
public static final String schemaNamespace = "http://www.w3.org/2001/XMLSchema";
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSContentType;
/**
* Marker interface that says this implementation
* implements XSContentType.
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public interface ContentTypeImpl extends Ref.ContentType, XSContentType {
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSDeclaration;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.util.NameGetter;
import org.xml.sax.Locator;
abstract class DeclarationImpl extends ComponentImpl implements XSDeclaration
{
DeclarationImpl( SchemaDocumentImpl owner,
AnnotationImpl _annon, Locator loc, ForeignAttributesImpl fa,
String _targetNamespace, String _name, boolean _anonymous ) {
super(owner,_annon,loc,fa);
this.targetNamespace = _targetNamespace;
this.name = _name;
this.anonymous = _anonymous;
}
private final String name;
public String getName() { return name; }
private final String targetNamespace;
public String getTargetNamespace() { return targetNamespace; }
private final boolean anonymous;
/** @deprecated */
public boolean isAnonymous() { return anonymous; }
public final boolean isGlobal() { return !isAnonymous(); }
public final boolean isLocal() { return isAnonymous(); }
}

View File

@@ -0,0 +1,235 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSTerm;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.XmlString;
import com.sun.xml.internal.xsom.impl.parser.PatcherManager;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunctionWithParam;
import com.sun.xml.internal.xsom.visitor.XSTermVisitor;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ElementDecl extends DeclarationImpl implements XSElementDecl, Ref.Term
{
public ElementDecl( PatcherManager reader, SchemaDocumentImpl owner,
AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa,
String _tns, String _name, boolean _anonymous,
XmlString _defv, XmlString _fixedv,
boolean _nillable, boolean _abstract, Boolean _form,
Ref.Type _type, Ref.Element _substHead,
int _substDisallowed, int _substExcluded,
List<IdentityConstraintImpl> idConstraints) {
super(owner,_annon,_loc,fa,_tns,_name,_anonymous);
this.defaultValue = _defv;
this.fixedValue = _fixedv;
this.nillable = _nillable;
this._abstract = _abstract;
this.form = _form;
this.type = _type;
this.substHead = _substHead;
this.substDisallowed = _substDisallowed;
this.substExcluded = _substExcluded;
this.idConstraints = Collections.unmodifiableList((List<? extends XSIdentityConstraint>)idConstraints);
for (IdentityConstraintImpl idc : idConstraints)
idc.setParent(this);
if(type==null)
throw new IllegalArgumentException();
}
private XmlString defaultValue;
public XmlString getDefaultValue() { return defaultValue; }
private XmlString fixedValue;
public XmlString getFixedValue() { return fixedValue; }
private boolean nillable;
public boolean isNillable() { return nillable; }
private boolean _abstract;
public boolean isAbstract() { return _abstract; }
private Ref.Type type;
public XSType getType() { return type.getType(); }
private Ref.Element substHead;
public XSElementDecl getSubstAffiliation() {
if(substHead==null) return null;
return substHead.get();
}
private int substDisallowed;
public boolean isSubstitutionDisallowed( int method ) {
return (substDisallowed&method)!=0;
}
private int substExcluded;
public boolean isSubstitutionExcluded( int method ) {
return (substExcluded&method)!=0;
}
private final List<XSIdentityConstraint> idConstraints;
public List<XSIdentityConstraint> getIdentityConstraints() {
return idConstraints;
}
private Boolean form;
public Boolean getForm() {
return form;
}
/**
* @deprecated
*/
public XSElementDecl[] listSubstitutables() {
Set<? extends XSElementDecl> s = getSubstitutables();
return s.toArray(new XSElementDecl[s.size()]);
}
/** Set that represents element decls that can substitute this element. */
private Set<XSElementDecl> substitutables = null;
/** Unmodifieable view of {@link #substitutables}. */
private Set<XSElementDecl> substitutablesView = null;
public Set<? extends XSElementDecl> getSubstitutables() {
if( substitutables==null ) {
// if the field is null by the time this method
// is called, it means this element is substitutable by itself only.
substitutables = substitutablesView = Collections.singleton((XSElementDecl)this);
}
return substitutablesView;
}
protected void addSubstitutable( ElementDecl decl ) {
if( substitutables==null ) {
substitutables = new HashSet<XSElementDecl>();
substitutables.add(this);
substitutablesView = Collections.unmodifiableSet(substitutables);
}
substitutables.add(decl);
}
public void updateSubstitutabilityMap() {
ElementDecl parent = this;
XSType type = this.getType();
boolean rused = false;
boolean eused = false;
while( (parent=(ElementDecl)parent.getSubstAffiliation())!=null ) {
if(parent.isSubstitutionDisallowed(XSType.SUBSTITUTION))
continue;
boolean rd = parent.isSubstitutionDisallowed(XSType.RESTRICTION);
boolean ed = parent.isSubstitutionDisallowed(XSType.EXTENSION);
if( (rd && rused) || ( ed && eused ) ) continue;
XSType parentType = parent.getType();
while (type!=parentType) {
if(type.getDerivationMethod()==XSType.RESTRICTION) rused = true;
else eused = true;
type = type.getBaseType();
if(type==null) // parentType and type doesn't share the common base type. a bug in the schema.
break;
if( type.isComplexType() ) {
rd |= type.asComplexType().isSubstitutionProhibited(XSType.RESTRICTION);
ed |= type.asComplexType().isSubstitutionProhibited(XSType.EXTENSION);
}
if (getRoot().getAnyType().equals(type)) break;
}
if( (rd && rused) || ( ed && eused ) ) continue;
// this element can substitute "parent"
parent.addSubstitutable(this);
}
}
public boolean canBeSubstitutedBy(XSElementDecl e) {
return getSubstitutables().contains(e);
}
public boolean isWildcard() { return false; }
public boolean isModelGroupDecl() { return false; }
public boolean isModelGroup() { return false; }
public boolean isElementDecl() { return true; }
public XSWildcard asWildcard() { return null; }
public XSModelGroupDecl asModelGroupDecl() { return null; }
public XSModelGroup asModelGroup() { return null; }
public XSElementDecl asElementDecl() { return this; }
public void visit( XSVisitor visitor ) {
visitor.elementDecl(this);
}
public void visit( XSTermVisitor visitor ) {
visitor.elementDecl(this);
}
public Object apply( XSTermFunction function ) {
return function.elementDecl(this);
}
public <T,P> T apply(XSTermFunctionWithParam<T, P> function, P param) {
return function.elementDecl(this,param);
}
public Object apply( XSFunction function ) {
return function.elementDecl(this);
}
// Ref.Term implementation
public XSTerm getTerm() { return this; }
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.visitor.XSContentTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
/**
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public class EmptyImpl extends ComponentImpl implements ContentTypeImpl {
public EmptyImpl() { super(null,null,null,null); }
public XSSimpleType asSimpleType() { return null; }
public XSParticle asParticle() { return null; }
public XSContentType asEmpty() { return this; }
public Object apply( XSContentTypeFunction function ) {
return function.empty(this);
}
public Object apply( XSFunction function ) {
return function.empty(this);
}
public void visit( XSVisitor visitor ) {
visitor.empty(this);
}
public void visit( XSContentTypeVisitor visitor ) {
visitor.empty(this);
}
public XSContentType getContentType() { return this; }
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XmlString;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
public class FacetImpl extends ComponentImpl implements XSFacet {
public FacetImpl( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
String _name, XmlString _value, boolean _fixed ) {
super(owner,_annon,_loc,_fa);
this.name = _name;
this.value = _value;
this.fixed = _fixed;
}
private final String name;
public String getName() { return name; }
private final XmlString value;
public XmlString getValue() { return value; }
private boolean fixed;
public boolean isFixed() { return fixed; }
public void visit( XSVisitor visitor ) {
visitor.facet(this);
}
public Object apply( XSFunction function ) {
return function.facet(this);
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.ForeignAttributes;
import org.relaxng.datatype.ValidationContext;
import org.xml.sax.Locator;
import org.xml.sax.helpers.AttributesImpl;
/**
* Remembers foreign attributes.
*
* @author Kohsuke Kawaguchi
*/
public final class ForeignAttributesImpl extends AttributesImpl implements ForeignAttributes {
private final ValidationContext context;
private final Locator locator;
/**
* {@link ForeignAttributes} forms a linked list.
*/
final ForeignAttributesImpl next;
public ForeignAttributesImpl(ValidationContext context, Locator locator, ForeignAttributesImpl next) {
this.context = context;
this.locator = locator;
this.next = next;
}
public ValidationContext getContext() {
return context;
}
public Locator getLocator() {
return locator;
}
}

View File

@@ -0,0 +1,116 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSXPath;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import java.util.Collections;
import java.util.List;
/**
* {@link XSIdentityConstraint} implementation.
*
* @author Kohsuke Kawaguchi
*/
public class IdentityConstraintImpl extends ComponentImpl implements XSIdentityConstraint, Ref.IdentityConstraint {
private XSElementDecl parent;
private final short category;
private final String name;
private final XSXPath selector;
private final List<XSXPath> fields;
private final Ref.IdentityConstraint refer;
public IdentityConstraintImpl(SchemaDocumentImpl _owner, AnnotationImpl _annon, Locator _loc,
ForeignAttributesImpl fa, short category, String name, XPathImpl selector,
List<XPathImpl> fields, Ref.IdentityConstraint refer) {
super(_owner, _annon, _loc, fa);
this.category = category;
this.name = name;
this.selector = selector;
selector.setParent(this);
this.fields = Collections.unmodifiableList((List<? extends XSXPath>)fields);
for( XPathImpl xp : fields )
xp.setParent(this);
this.refer = refer;
}
public void visit(XSVisitor visitor) {
visitor.identityConstraint(this);
}
public <T> T apply(XSFunction<T> function) {
return function.identityConstraint(this);
}
public void setParent(ElementDecl parent) {
this.parent = parent;
parent.getOwnerSchema().addIdentityConstraint(this);
}
public XSElementDecl getParent() {
return parent;
}
public String getName() {
return name;
}
public String getTargetNamespace() {
return getParent().getTargetNamespace();
}
public short getCategory() {
return category;
}
public XSXPath getSelector() {
return selector;
}
public List<XSXPath> getFields() {
return fields;
}
public XSIdentityConstraint getReferencedKey() {
if(category==KEYREF)
return refer.get();
else
throw new IllegalStateException("not a keyref");
}
public XSIdentityConstraint get() {
return this;
}
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSListSimpleType;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSVariety;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor;
import org.xml.sax.Locator;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public class ListSimpleTypeImpl extends SimpleTypeImpl implements XSListSimpleType
{
public ListSimpleTypeImpl( SchemaDocumentImpl _parent,
AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
String _name, boolean _anonymous, Set<XSVariety> finalSet,
Ref.SimpleType _itemType ) {
super(_parent,_annon,_loc,_fa,_name,_anonymous, finalSet,
_parent.getSchema().parent.anySimpleType);
this.itemType = _itemType;
}
private final Ref.SimpleType itemType;
public XSSimpleType getItemType() { return itemType.getType(); }
public void visit( XSSimpleTypeVisitor visitor ) {
visitor.listSimpleType(this);
}
public Object apply( XSSimpleTypeFunction function ) {
return function.listSimpleType(this);
}
// list type by itself doesn't have any facet. */
public XSFacet getFacet( String name ) { return null; }
public List<XSFacet> getFacets( String name ) { return Collections.EMPTY_LIST; }
public XSVariety getVariety() { return XSVariety.LIST; }
public XSSimpleType getPrimitiveType() { return null; }
public XSListSimpleType getBaseListType() {return this;}
public boolean isList() { return true; }
public XSListSimpleType asList() { return this; }
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSTerm;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunctionWithParam;
import com.sun.xml.internal.xsom.visitor.XSTermVisitor;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
public class ModelGroupDeclImpl extends DeclarationImpl implements XSModelGroupDecl, Ref.Term
{
public ModelGroupDeclImpl( SchemaDocumentImpl owner,
AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
String _targetNamespace, String _name,
ModelGroupImpl _modelGroup ) {
super(owner,_annon,_loc,_fa,_targetNamespace,_name,false);
this.modelGroup = _modelGroup;
if(modelGroup==null)
throw new IllegalArgumentException();
}
private final ModelGroupImpl modelGroup;
public XSModelGroup getModelGroup() { return modelGroup; }
/**
* This component is a redefinition of "oldMG". Fix up the internal state
* as such.
*/
public void redefine( ModelGroupDeclImpl oldMG ) {
modelGroup.redefine(oldMG);
}
public void visit( XSVisitor visitor ) {
visitor.modelGroupDecl(this);
}
public void visit( XSTermVisitor visitor ) {
visitor.modelGroupDecl(this);
}
public Object apply( XSTermFunction function ) {
return function.modelGroupDecl(this);
}
public <T,P> T apply(XSTermFunctionWithParam<T, P> function, P param) {
return function.modelGroupDecl(this,param);
}
public Object apply( XSFunction function ) {
return function.modelGroupDecl(this);
}
public boolean isWildcard() { return false; }
public boolean isModelGroupDecl() { return true; }
public boolean isModelGroup() { return false; }
public boolean isElementDecl() { return false; }
public XSWildcard asWildcard() { return null; }
public XSModelGroupDecl asModelGroupDecl() { return this; }
public XSModelGroup asModelGroup() { return null; }
public XSElementDecl asElementDecl() { return null; }
// Ref.Term implementation
public XSTerm getTerm() { return this; }
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSTerm;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunctionWithParam;
import com.sun.xml.internal.xsom.visitor.XSTermVisitor;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import java.util.Arrays;
import java.util.Iterator;
public class ModelGroupImpl extends ComponentImpl implements XSModelGroup, Ref.Term
{
public ModelGroupImpl( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
Compositor _compositor, ParticleImpl[] _children ) {
super(owner,_annon,_loc,_fa);
this.compositor = _compositor;
this.children = _children;
if(compositor==null)
throw new IllegalArgumentException();
for( int i=children.length-1; i>=0; i-- )
if(children[i]==null)
throw new IllegalArgumentException();
}
private final ParticleImpl[] children;
public ParticleImpl getChild( int idx ) { return children[idx]; }
public int getSize() { return children.length; }
public ParticleImpl[] getChildren() { return children; }
private final Compositor compositor;
public Compositor getCompositor() { return compositor; }
public void redefine(ModelGroupDeclImpl oldMG) {
for (ParticleImpl p : children)
p.redefine(oldMG);
}
public Iterator<XSParticle> iterator() {
return Arrays.asList((XSParticle[])children).iterator();
}
public boolean isWildcard() { return false; }
public boolean isModelGroupDecl() { return false; }
public boolean isModelGroup() { return true; }
public boolean isElementDecl() { return false; }
public XSWildcard asWildcard() { return null; }
public XSModelGroupDecl asModelGroupDecl() { return null; }
public XSModelGroup asModelGroup() { return this; }
public XSElementDecl asElementDecl() { return null; }
public void visit( XSVisitor visitor ) {
visitor.modelGroup(this);
}
public void visit( XSTermVisitor visitor ) {
visitor.modelGroup(this);
}
public Object apply( XSTermFunction function ) {
return function.modelGroup(this);
}
public <T,P> T apply(XSTermFunctionWithParam<T, P> function, P param) {
return function.modelGroup(this,param);
}
public Object apply( XSFunction function ) {
return function.modelGroup(this);
}
// Ref.Term implementation
public XSTerm getTerm() { return this; }
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSNotation;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
/**
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public class NotationImpl extends DeclarationImpl implements XSNotation {
public NotationImpl( SchemaDocumentImpl owner, AnnotationImpl _annon,
Locator _loc, ForeignAttributesImpl _fa, String _name,
String _publicId, String _systemId ) {
super(owner,_annon,_loc,_fa,owner.getTargetNamespace(),_name,false);
this.publicId = _publicId;
this.systemId = _systemId;
}
private final String publicId;
private final String systemId;
public String getPublicId() { return publicId; }
public String getSystemId() { return systemId; }
public void visit(XSVisitor visitor) {
visitor.notation(this);
}
public Object apply(XSFunction function) {
return function.notation(this);
}
}

View File

@@ -0,0 +1,119 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSTerm;
import com.sun.xml.internal.xsom.impl.parser.DelayedRef;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSContentTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import java.math.BigInteger;
import org.xml.sax.Locator;
import java.util.List;
public class ParticleImpl extends ComponentImpl implements XSParticle, ContentTypeImpl
{
public ParticleImpl( SchemaDocumentImpl owner, AnnotationImpl _ann,
Ref.Term _term, Locator _loc, BigInteger _maxOccurs, BigInteger _minOccurs ) {
super(owner,_ann,_loc,null);
this.term = _term;
this.maxOccurs = _maxOccurs;
this.minOccurs = _minOccurs;
}
public ParticleImpl( SchemaDocumentImpl owner, AnnotationImpl _ann,
Ref.Term _term, Locator _loc, int _maxOccurs, int _minOccurs ) {
super(owner,_ann,_loc,null);
this.term = _term;
this.maxOccurs = BigInteger.valueOf(_maxOccurs);
this.minOccurs = BigInteger.valueOf(_minOccurs);
}
public ParticleImpl( SchemaDocumentImpl owner, AnnotationImpl _ann, Ref.Term _term, Locator _loc ) {
this(owner,_ann,_term,_loc,1,1);
}
private Ref.Term term;
public XSTerm getTerm() { return term.getTerm(); }
private BigInteger maxOccurs;
public BigInteger getMaxOccurs() { return maxOccurs; }
public boolean isRepeated() {
return !maxOccurs.equals(BigInteger.ZERO) && !maxOccurs.equals(BigInteger.ONE);
}
private BigInteger minOccurs;
public BigInteger getMinOccurs() { return minOccurs; }
public void redefine(ModelGroupDeclImpl oldMG) {
if( term instanceof ModelGroupImpl ) {
((ModelGroupImpl)term).redefine(oldMG);
return;
}
if( term instanceof DelayedRef.ModelGroup ) {
((DelayedRef)term).redefine(oldMG);
}
}
public XSSimpleType asSimpleType() { return null; }
public XSParticle asParticle() { return this; }
public XSContentType asEmpty() { return null; }
public final Object apply( XSFunction function ) {
return function.particle(this);
}
public final Object apply( XSContentTypeFunction function ) {
return function.particle(this);
}
public final void visit( XSVisitor visitor ) {
visitor.particle(this);
}
public final void visit( XSContentTypeVisitor visitor ) {
visitor.particle(this);
}
// Ref.ContentType implementation
public XSContentType getContentType() { return this; }
/**
* Foreign attribuets are considered to be on terms.
*
* REVISIT: is this a good design?
*/
public List getForeignAttributes() {
return getTerm().getForeignAttributes();
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSTerm;
import com.sun.xml.internal.xsom.XSType;
/**
* Reference to other schema components.
*
* <p>
* There are mainly two different types of references. One is
* the direct reference, which is only possible when schema components
* are already available when references are made.
* The other is the lazy reference, which keeps references by names
* and later look for the component by name.
*
* <p>
* This class defines interfaces that define the behavior of such
* references and classes that implement direct reference semantics.
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public abstract class Ref {
public static interface Term {
/** Obtains a reference as a term. */
XSTerm getTerm();
}
public static interface Type {
/** Obtains a reference as a type. */
XSType getType();
}
public static interface ContentType {
XSContentType getContentType();
}
public static interface SimpleType extends Ref.Type {
public XSSimpleType getType();
}
public static interface ComplexType extends Ref.Type {
public XSComplexType getType();
}
public static interface Attribute {
XSAttributeDecl getAttribute();
}
public static interface AttGroup {
XSAttGroupDecl get();
}
public static interface Element extends Term {
XSElementDecl get();
}
public static interface IdentityConstraint {
XSIdentityConstraint get();
}
//
//
// private static void _assert( boolean b ) {
// if(!b)
// throw new InternalError("assertion failed");
// }
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSRestrictionSimpleType;
import com.sun.xml.internal.xsom.XSVariety;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor;
import org.xml.sax.Locator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class RestrictionSimpleTypeImpl extends SimpleTypeImpl implements XSRestrictionSimpleType {
public RestrictionSimpleTypeImpl( SchemaDocumentImpl _parent,
AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
String _name, boolean _anonymous, Set<XSVariety> finalSet,
Ref.SimpleType _baseType ) {
super( _parent, _annon, _loc, _fa, _name, _anonymous, finalSet, _baseType );
}
private final List<XSFacet> facets = new ArrayList<XSFacet>();
public void addFacet( XSFacet facet ) {
facets.add(facet);
}
public Iterator<XSFacet> iterateDeclaredFacets() {
return facets.iterator();
}
public Collection<? extends XSFacet> getDeclaredFacets() {
return facets;
}
public XSFacet getDeclaredFacet( String name ) {
int len = facets.size();
for( int i=0; i<len; i++ ) {
XSFacet f = facets.get(i);
if(f.getName().equals(name))
return f;
}
return null;
}
public List<XSFacet> getDeclaredFacets(String name) {
List<XSFacet> r = new ArrayList<XSFacet>();
for( XSFacet f : facets )
if(f.getName().equals(name))
r.add(f);
return r;
}
public XSFacet getFacet( String name ) {
XSFacet f = getDeclaredFacet(name);
if(f!=null) return f;
// none was found on this datatype. check the base type.
return getSimpleBaseType().getFacet(name);
}
public List<XSFacet> getFacets( String name ) {
List<XSFacet> f = getDeclaredFacets(name);
if(!f.isEmpty()) return f;
// none was found on this datatype. check the base type.
return getSimpleBaseType().getFacets(name);
}
public XSVariety getVariety() { return getSimpleBaseType().getVariety(); }
public XSSimpleType getPrimitiveType() {
if(isPrimitive()) return this;
return getSimpleBaseType().getPrimitiveType();
}
public boolean isPrimitive() {
return getSimpleBaseType()==getOwnerSchema().getRoot().anySimpleType;
}
public void visit( XSSimpleTypeVisitor visitor ) {
visitor.restrictionSimpleType(this);
}
public Object apply( XSSimpleTypeFunction function ) {
return function.restrictionSimpleType(this);
}
public boolean isRestriction() { return true; }
public XSRestrictionSimpleType asRestriction() { return this; }
}

View File

@@ -0,0 +1,309 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.ForeignAttributes;
import com.sun.xml.internal.xsom.SCD;
import com.sun.xml.internal.xsom.XSAnnotation;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSComponent;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSNotation;
import com.sun.xml.internal.xsom.XSSchema;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.parser.SchemaDocument;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import javax.xml.namespace.NamespaceContext;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class SchemaImpl implements XSSchema
{
public SchemaImpl(SchemaSetImpl _parent, Locator loc, String tns) {
if (tns == null)
// the empty string must be used.
throw new IllegalArgumentException();
this.targetNamespace = tns;
this.parent = _parent;
this.locator = loc;
}
public SchemaDocument getSourceDocument() {
return null;
}
public SchemaSetImpl getRoot() {
return parent;
}
protected final SchemaSetImpl parent;
private final String targetNamespace;
public String getTargetNamespace() {
return targetNamespace;
}
public XSSchema getOwnerSchema() {
return this;
}
private XSAnnotation annotation;
public void setAnnotation(XSAnnotation a) {
annotation = a;
}
public XSAnnotation getAnnotation() {
return annotation;
}
public XSAnnotation getAnnotation(boolean createIfNotExist) {
if(createIfNotExist && annotation==null)
annotation = new AnnotationImpl();
return annotation;
}
// it's difficult to determine the source location for the schema
// component as one schema can be defined across multiple files.
// so this locator might not correctly reflect all the locations
// where the schema is defined.
// but partial information would be better than nothing.
private final Locator locator;
public Locator getLocator() {
return locator;
}
private final Map<String,XSAttributeDecl> atts = new HashMap<String,XSAttributeDecl>();
private final Map<String,XSAttributeDecl> attsView = Collections.unmodifiableMap(atts);
public void addAttributeDecl(XSAttributeDecl newDecl) {
atts.put(newDecl.getName(), newDecl);
}
public Map<String,XSAttributeDecl> getAttributeDecls() {
return attsView;
}
public XSAttributeDecl getAttributeDecl(String name) {
return atts.get(name);
}
public Iterator<XSAttributeDecl> iterateAttributeDecls() {
return atts.values().iterator();
}
private final Map<String,XSElementDecl> elems = new HashMap<String,XSElementDecl>();
private final Map<String,XSElementDecl> elemsView = Collections.unmodifiableMap(elems);
public void addElementDecl(XSElementDecl newDecl) {
elems.put(newDecl.getName(), newDecl);
}
public Map<String,XSElementDecl> getElementDecls() {
return elemsView;
}
public XSElementDecl getElementDecl(String name) {
return elems.get(name);
}
public Iterator<XSElementDecl> iterateElementDecls() {
return elems.values().iterator();
}
private final Map<String,XSAttGroupDecl> attGroups = new HashMap<String,XSAttGroupDecl>();
private final Map<String,XSAttGroupDecl> attGroupsView = Collections.unmodifiableMap(attGroups);
public void addAttGroupDecl(XSAttGroupDecl newDecl, boolean overwrite) {
if(overwrite || !attGroups.containsKey(newDecl.getName()))
attGroups.put(newDecl.getName(), newDecl);
}
public Map<String,XSAttGroupDecl> getAttGroupDecls() {
return attGroupsView;
}
public XSAttGroupDecl getAttGroupDecl(String name) {
return attGroups.get(name);
}
public Iterator<XSAttGroupDecl> iterateAttGroupDecls() {
return attGroups.values().iterator();
}
private final Map<String,XSNotation> notations = new HashMap<String,XSNotation>();
private final Map<String,XSNotation> notationsView = Collections.unmodifiableMap(notations);
public void addNotation( XSNotation newDecl ) {
notations.put( newDecl.getName(), newDecl );
}
public Map<String,XSNotation> getNotations() {
return notationsView;
}
public XSNotation getNotation( String name ) {
return notations.get(name);
}
public Iterator<XSNotation> iterateNotations() {
return notations.values().iterator();
}
private final Map<String,XSModelGroupDecl> modelGroups = new HashMap<String,XSModelGroupDecl>();
private final Map<String,XSModelGroupDecl> modelGroupsView = Collections.unmodifiableMap(modelGroups);
public void addModelGroupDecl(XSModelGroupDecl newDecl, boolean overwrite) {
if(overwrite || !modelGroups.containsKey(newDecl.getName()))
modelGroups.put(newDecl.getName(), newDecl);
}
public Map<String,XSModelGroupDecl> getModelGroupDecls() {
return modelGroupsView;
}
public XSModelGroupDecl getModelGroupDecl(String name) {
return modelGroups.get(name);
}
public Iterator<XSModelGroupDecl> iterateModelGroupDecls() {
return modelGroups.values().iterator();
}
private final Map<String,XSIdentityConstraint> idConstraints = new HashMap<String,XSIdentityConstraint>();
private final Map<String,XSIdentityConstraint> idConstraintsView = Collections.unmodifiableMap(idConstraints);
protected void addIdentityConstraint(IdentityConstraintImpl c) {
idConstraints.put(c.getName(),c);
}
public Map<String, XSIdentityConstraint> getIdentityConstraints() {
return idConstraintsView;
}
public XSIdentityConstraint getIdentityConstraint(String localName) {
return idConstraints.get(localName);
}
private final Map<String,XSType> allTypes = new HashMap<String,XSType>();
private final Map<String,XSType> allTypesView = Collections.unmodifiableMap(allTypes);
private final Map<String,XSSimpleType> simpleTypes = new HashMap<String,XSSimpleType>();
private final Map<String,XSSimpleType> simpleTypesView = Collections.unmodifiableMap(simpleTypes);
public void addSimpleType(XSSimpleType newDecl, boolean overwrite) {
if(overwrite || !simpleTypes.containsKey(newDecl.getName())) {
simpleTypes.put(newDecl.getName(), newDecl);
allTypes.put(newDecl.getName(), newDecl);
}
}
public Map<String,XSSimpleType> getSimpleTypes() {
return simpleTypesView;
}
public XSSimpleType getSimpleType(String name) {
return simpleTypes.get(name);
}
public Iterator<XSSimpleType> iterateSimpleTypes() {
return simpleTypes.values().iterator();
}
private final Map<String,XSComplexType> complexTypes = new HashMap<String,XSComplexType>();
private final Map<String,XSComplexType> complexTypesView = Collections.unmodifiableMap(complexTypes);
public void addComplexType(XSComplexType newDecl, boolean overwrite) {
if(overwrite || !complexTypes.containsKey(newDecl.getName())) {
complexTypes.put(newDecl.getName(), newDecl);
allTypes.put(newDecl.getName(), newDecl);
}
}
public Map<String,XSComplexType> getComplexTypes() {
return complexTypesView;
}
public XSComplexType getComplexType(String name) {
return complexTypes.get(name);
}
public Iterator<XSComplexType> iterateComplexTypes() {
return complexTypes.values().iterator();
}
public Map<String,XSType> getTypes() {
return allTypesView;
}
public XSType getType(String name) {
return allTypes.get(name);
}
public Iterator<XSType> iterateTypes() {
return allTypes.values().iterator();
}
public void visit(XSVisitor visitor) {
visitor.schema(this);
}
public Object apply(XSFunction function) {
return function.schema(this);
}
/**
* Lazily created list of {@link ForeignAttributesImpl}s.
*/
private List<ForeignAttributes> foreignAttributes = null;
private List<ForeignAttributes> readOnlyForeignAttributes = null;
public void addForeignAttributes(ForeignAttributesImpl fa) {
if(foreignAttributes==null)
foreignAttributes = new ArrayList<ForeignAttributes>();
foreignAttributes.add(fa);
}
public List<ForeignAttributes> getForeignAttributes() {
if(readOnlyForeignAttributes==null) {
if(foreignAttributes==null)
readOnlyForeignAttributes = Collections.EMPTY_LIST;
else
readOnlyForeignAttributes = Collections.unmodifiableList(foreignAttributes);
}
return readOnlyForeignAttributes;
}
public String getForeignAttribute(String nsUri, String localName) {
for( ForeignAttributes fa : getForeignAttributes() ) {
String v = fa.getValue(nsUri,localName);
if(v!=null) return v;
}
return null;
}
public Collection<XSComponent> select(String scd, NamespaceContext nsContext) {
try {
return SCD.create(scd,nsContext).select(this);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
public XSComponent selectSingle(String scd, NamespaceContext nsContext) {
try {
return SCD.create(scd,nsContext).selectSingle(this);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
}

View File

@@ -0,0 +1,394 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.SCD;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSComponent;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSListSimpleType;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSNotation;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSRestrictionSimpleType;
import com.sun.xml.internal.xsom.XSSchema;
import com.sun.xml.internal.xsom.XSSchemaSet;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.XSUnionSimpleType;
import com.sun.xml.internal.xsom.XSVariety;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.impl.scd.Iterators;
import com.sun.xml.internal.xsom.visitor.XSContentTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import javax.xml.namespace.NamespaceContext;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
public class SchemaSetImpl implements XSSchemaSet
{
private final Map<String,XSSchema> schemas = new HashMap<String,XSSchema>();
private final Vector<XSSchema> schemas2 = new Vector<XSSchema>();
private final List<XSSchema> readonlySchemaList = Collections.unmodifiableList(schemas2);
/**
* Gets a reference to the existing schema or creates a new one
* if none exists yet.
*/
public SchemaImpl createSchema(String targetNamespace, Locator location) {
SchemaImpl obj = (SchemaImpl)schemas.get(targetNamespace);
if (obj == null) {
obj = new SchemaImpl(this, location, targetNamespace);
schemas.put(targetNamespace, obj);
schemas2.add(obj);
}
return obj;
}
public int getSchemaSize() {
return schemas.size();
}
public XSSchema getSchema(String targetNamespace) {
return schemas.get(targetNamespace);
}
public XSSchema getSchema(int idx) {
return schemas2.get(idx);
}
public Iterator<XSSchema> iterateSchema() {
return schemas2.iterator();
}
public final Collection<XSSchema> getSchemas() {
return readonlySchemaList;
}
public XSType getType(String ns, String localName) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getType(localName);
}
public XSSimpleType getSimpleType( String ns, String localName ) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getSimpleType(localName);
}
public XSElementDecl getElementDecl( String ns, String localName ) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getElementDecl(localName);
}
public XSAttributeDecl getAttributeDecl( String ns, String localName ) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getAttributeDecl(localName);
}
public XSModelGroupDecl getModelGroupDecl( String ns, String localName ) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getModelGroupDecl(localName);
}
public XSAttGroupDecl getAttGroupDecl( String ns, String localName ) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getAttGroupDecl(localName);
}
public XSComplexType getComplexType( String ns, String localName ) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getComplexType(localName);
}
public XSIdentityConstraint getIdentityConstraint(String ns, String localName) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getIdentityConstraint(localName);
}
public Iterator<XSElementDecl> iterateElementDecls() {
return new Iterators.Map<XSElementDecl,XSSchema>(iterateSchema()) {
protected Iterator<XSElementDecl> apply(XSSchema u) {
return u.iterateElementDecls();
}
};
}
public Iterator<XSType> iterateTypes() {
return new Iterators.Map<XSType,XSSchema>(iterateSchema()) {
protected Iterator<XSType> apply(XSSchema u) {
return u.iterateTypes();
}
};
}
public Iterator<XSAttributeDecl> iterateAttributeDecls() {
return new Iterators.Map<XSAttributeDecl,XSSchema>(iterateSchema()) {
protected Iterator<XSAttributeDecl> apply(XSSchema u) {
return u.iterateAttributeDecls();
}
};
}
public Iterator<XSAttGroupDecl> iterateAttGroupDecls() {
return new Iterators.Map<XSAttGroupDecl,XSSchema>(iterateSchema()) {
protected Iterator<XSAttGroupDecl> apply(XSSchema u) {
return u.iterateAttGroupDecls();
}
};
}
public Iterator<XSModelGroupDecl> iterateModelGroupDecls() {
return new Iterators.Map<XSModelGroupDecl,XSSchema>(iterateSchema()) {
protected Iterator<XSModelGroupDecl> apply(XSSchema u) {
return u.iterateModelGroupDecls();
}
};
}
public Iterator<XSSimpleType> iterateSimpleTypes() {
return new Iterators.Map<XSSimpleType,XSSchema>(iterateSchema()) {
protected Iterator<XSSimpleType> apply(XSSchema u) {
return u.iterateSimpleTypes();
}
};
}
public Iterator<XSComplexType> iterateComplexTypes() {
return new Iterators.Map<XSComplexType,XSSchema>(iterateSchema()) {
protected Iterator<XSComplexType> apply(XSSchema u) {
return u.iterateComplexTypes();
}
};
}
public Iterator<XSNotation> iterateNotations() {
return new Iterators.Map<XSNotation,XSSchema>(iterateSchema()) {
protected Iterator<XSNotation> apply(XSSchema u) {
return u.iterateNotations();
}
};
}
public Iterator<XSIdentityConstraint> iterateIdentityConstraints() {
return new Iterators.Map<XSIdentityConstraint,XSSchema>(iterateSchema()) {
protected Iterator<XSIdentityConstraint> apply(XSSchema u) {
return u.getIdentityConstraints().values().iterator();
}
};
}
public Collection<XSComponent> select(String scd, NamespaceContext nsContext) {
try {
return SCD.create(scd,nsContext).select(this);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
public XSComponent selectSingle(String scd, NamespaceContext nsContext) {
try {
return SCD.create(scd,nsContext).selectSingle(this);
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
public final EmptyImpl empty = new EmptyImpl();
public XSContentType getEmpty() { return empty; }
public XSSimpleType getAnySimpleType() { return anySimpleType; }
public final AnySimpleType anySimpleType = new AnySimpleType();
private class AnySimpleType extends DeclarationImpl
implements XSRestrictionSimpleType, Ref.SimpleType {
AnySimpleType() {
super(null,null,null,null,"http://www.w3.org/2001/XMLSchema","anySimpleType",false);
}
public SchemaImpl getOwnerSchema() {
return createSchema("http://www.w3.org/2001/XMLSchema",null);
}
public XSSimpleType asSimpleType() { return this; }
public XSComplexType asComplexType() { return null; }
public boolean isDerivedFrom(XSType t) {
return t==this || t==anyType;
}
public boolean isSimpleType() { return true; }
public boolean isComplexType() { return false; }
public XSContentType asEmpty() { return null; }
public XSParticle asParticle() { return null; }
public XSType getBaseType() { return anyType; }
public XSSimpleType getSimpleBaseType() { return null; }
public int getDerivationMethod() { return RESTRICTION; }
public Iterator<XSFacet> iterateDeclaredFacets() { return Iterators.empty(); }
public Collection<? extends XSFacet> getDeclaredFacets() { return Collections.EMPTY_LIST; }
public void visit( XSSimpleTypeVisitor visitor ) {visitor.restrictionSimpleType(this); }
public void visit( XSContentTypeVisitor visitor ) {visitor.simpleType(this); }
public void visit( XSVisitor visitor ) {visitor.simpleType(this); }
public <T> T apply( XSSimpleTypeFunction<T> f ) {return f.restrictionSimpleType(this); }
public <T> T apply( XSContentTypeFunction<T> f ) { return f.simpleType(this); }
public <T> T apply( XSFunction<T> f ) { return f.simpleType(this); }
public XSVariety getVariety() { return XSVariety.ATOMIC; }
public XSSimpleType getPrimitiveType() {return this;}
public boolean isPrimitive() {return true;}
public XSListSimpleType getBaseListType() {return null;}
public XSUnionSimpleType getBaseUnionType() {return null;}
public XSFacet getFacet(String name) { return null; }
public List<XSFacet> getFacets( String name ) { return Collections.EMPTY_LIST; }
public XSFacet getDeclaredFacet(String name) { return null; }
public List<XSFacet> getDeclaredFacets(String name) { return Collections.EMPTY_LIST; }
public boolean isRestriction() { return true; }
public boolean isList() { return false; }
public boolean isUnion() { return false; }
public boolean isFinal(XSVariety v) { return false; }
public XSRestrictionSimpleType asRestriction() { return this; }
public XSListSimpleType asList() { return null; }
public XSUnionSimpleType asUnion() { return null; }
public XSSimpleType getType() { return this; } // Ref.SimpleType implementation
public XSSimpleType getRedefinedBy() { return null; }
public int getRedefinedCount() { return 0; }
public XSType[] listSubstitutables() {
return Util.listSubstitutables(this);
}
}
public XSComplexType getAnyType() { return anyType; }
public final AnyType anyType = new AnyType();
private class AnyType extends DeclarationImpl implements XSComplexType, Ref.Type {
AnyType() {
super(null,null,null,null,"http://www.w3.org/2001/XMLSchema","anyType",false);
}
public SchemaImpl getOwnerSchema() {
return createSchema("http://www.w3.org/2001/XMLSchema",null);
}
public boolean isAbstract() { return false; }
public XSWildcard getAttributeWildcard() { return anyWildcard; }
public XSAttributeUse getAttributeUse( String nsURI, String localName ) { return null; }
public Iterator<XSAttributeUse> iterateAttributeUses() { return Iterators.empty(); }
public XSAttributeUse getDeclaredAttributeUse( String nsURI, String localName ) { return null; }
public Iterator<XSAttributeUse> iterateDeclaredAttributeUses() { return Iterators.empty(); }
public Iterator<XSAttGroupDecl> iterateAttGroups() { return Iterators.empty(); }
public Collection<XSAttributeUse> getAttributeUses() { return Collections.EMPTY_LIST; }
public Collection<? extends XSAttributeUse> getDeclaredAttributeUses() { return Collections.EMPTY_LIST; }
public Collection<? extends XSAttGroupDecl> getAttGroups() { return Collections.EMPTY_LIST; }
public boolean isFinal( int i ) { return false; }
public boolean isSubstitutionProhibited( int i ) { return false; }
public boolean isMixed() { return true; }
public XSContentType getContentType() { return contentType; }
public XSContentType getExplicitContent() { return null; }
public XSType getBaseType() { return this; }
public XSSimpleType asSimpleType() { return null; }
public XSComplexType asComplexType() { return this; }
public boolean isDerivedFrom(XSType t) {
return t==this;
}
public boolean isSimpleType() { return false; }
public boolean isComplexType() { return true; }
public XSContentType asEmpty() { return null; }
public int getDerivationMethod() { return XSType.RESTRICTION; }
public XSElementDecl getScope() { return null; }
public void visit( XSVisitor visitor ) { visitor.complexType(this); }
public <T> T apply( XSFunction<T> f ) { return f.complexType(this); }
public XSType getType() { return this; } // Ref.Type implementation
public XSComplexType getRedefinedBy() { return null; }
public int getRedefinedCount() { return 0; }
public XSType[] listSubstitutables() {
return Util.listSubstitutables(this);
}
private final WildcardImpl anyWildcard = new WildcardImpl.Any(null,null,null,null,XSWildcard.SKIP);
private final XSContentType contentType = new ParticleImpl( null, null,
new ModelGroupImpl(null, null, null, null,XSModelGroup.SEQUENCE, new ParticleImpl[]{
new ParticleImpl( null, null,
anyWildcard, null,
XSParticle.UNBOUNDED, 0 )
})
,null,1,1);
public List<XSComplexType> getSubtypes() {
ArrayList subtypeList = new ArrayList();
Iterator<XSComplexType> cTypes = getRoot().iterateComplexTypes();
while (cTypes.hasNext()) {
XSComplexType cType= cTypes.next();
XSType base = cType.getBaseType();
if ((base != null) && (base.equals(this))) {
subtypeList.add(cType);
}
}
return subtypeList;
}
public List<XSElementDecl> getElementDecls() {
ArrayList declList = new ArrayList();
XSSchemaSet schemaSet = getRoot();
for (XSSchema sch : schemaSet.getSchemas()) {
for (XSElementDecl decl : sch.getElementDecls().values()) {
if (decl.getType().equals(this)) {
declList.add(decl);
}
}
}
return declList;
}
}
}

View File

@@ -0,0 +1,165 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSListSimpleType;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSRestrictionSimpleType;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.XSUnionSimpleType;
import com.sun.xml.internal.xsom.XSVariety;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSContentTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
import java.util.Set;
public abstract class SimpleTypeImpl extends DeclarationImpl
implements XSSimpleType, ContentTypeImpl, Ref.SimpleType
{
SimpleTypeImpl(
SchemaDocumentImpl _parent,
AnnotationImpl _annon,
Locator _loc,
ForeignAttributesImpl _fa,
String _name,
boolean _anonymous,
Set<XSVariety> finalSet,
Ref.SimpleType _baseType) {
super(_parent, _annon, _loc, _fa, _parent.getTargetNamespace(), _name, _anonymous);
this.baseType = _baseType;
this.finalSet = finalSet;
}
private Ref.SimpleType baseType;
public XSType[] listSubstitutables() {
return Util.listSubstitutables(this);
}
public void redefine( SimpleTypeImpl st ) {
baseType = st;
st.redefinedBy = this;
redefiningCount = (short)(st.redefiningCount+1);
}
/**
* Number of times this component redefines other components.
*/
private short redefiningCount = 0;
private SimpleTypeImpl redefinedBy = null;
public XSSimpleType getRedefinedBy() {
return redefinedBy;
}
public int getRedefinedCount() {
int i=0;
for( SimpleTypeImpl st =this.redefinedBy; st !=null; st =st.redefinedBy)
i++;
return i;
}
public XSType getBaseType() { return baseType.getType(); }
public XSSimpleType getSimpleBaseType() { return baseType.getType(); }
public boolean isPrimitive() { return false; }
public XSListSimpleType getBaseListType() {
return getSimpleBaseType().getBaseListType();
}
public XSUnionSimpleType getBaseUnionType() {
return getSimpleBaseType().getBaseUnionType();
}
private final Set<XSVariety> finalSet;
public boolean isFinal(XSVariety v) {
return finalSet.contains(v);
}
public final int getDerivationMethod() { return XSType.RESTRICTION; }
public final XSSimpleType asSimpleType() { return this; }
public final XSComplexType asComplexType(){ return null; }
public boolean isDerivedFrom(XSType t) {
XSType x = this;
while(true) {
if(t==x)
return true;
XSType s = x.getBaseType();
if(s==x)
return false;
x = s;
}
}
public final boolean isSimpleType() { return true; }
public final boolean isComplexType() { return false; }
public final XSParticle asParticle() { return null; }
public final XSContentType asEmpty() { return null; }
public boolean isRestriction() { return false; }
public boolean isList() { return false; }
public boolean isUnion() { return false; }
public XSRestrictionSimpleType asRestriction() { return null; }
public XSListSimpleType asList() { return null; }
public XSUnionSimpleType asUnion() { return null; }
public final void visit( XSVisitor visitor ) {
visitor.simpleType(this);
}
public final void visit( XSContentTypeVisitor visitor ) {
visitor.simpleType(this);
}
public final Object apply( XSFunction function ) {
return function.simpleType(this);
}
public final Object apply( XSContentTypeFunction function ) {
return function.simpleType(this);
}
// Ref.ContentType implementation
public XSContentType getContentType() { return this; }
// Ref.SimpleType implementation
public XSSimpleType getType() { return this; }
}

View File

@@ -0,0 +1,105 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSDeclaration;
import java.util.Comparator;
/**
* UName.
*
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public final class UName {
/**
* @param _nsUri
* Use "" to indicate the no namespace.
*/
public UName( String _nsUri, String _localName, String _qname ) {
if(_nsUri==null || _localName==null || _qname==null) {
throw new NullPointerException(_nsUri+" "+_localName+" "+_qname);
}
this.nsUri = _nsUri.intern();
this.localName = _localName.intern();
this.qname = _qname.intern();
}
public UName( String nsUri, String localName ) {
this(nsUri,localName,localName);
}
public UName(XSDeclaration decl) {
this(decl.getTargetNamespace(),decl.getName());
}
private final String nsUri;
private final String localName;
private final String qname;
public String getName() { return localName; }
public String getNamespaceURI() { return nsUri; }
public String getQualifiedName() { return qname; }
// Issue 540; XSComplexType.getAttributeUse(String,String) always return null
// UName was used in HashMap without overriden equals and hashCode methods.
@Override
public boolean equals(Object obj) {
if(obj instanceof UName) {
UName u = (UName)obj;
return ((this.getName().compareTo(u.getName()) == 0) &&
(this.getNamespaceURI().compareTo(u.getNamespaceURI()) == 0) &&
(this.getQualifiedName().compareTo(u.getQualifiedName()) == 0));
} else {
return false;
}
}
@Override
public int hashCode() {
int hash = 7;
hash = 13 * hash + (this.nsUri != null ? this.nsUri.hashCode() : 0);
hash = 13 * hash + (this.localName != null ? this.localName.hashCode() : 0);
hash = 13 * hash + (this.qname != null ? this.qname.hashCode() : 0);
return hash;
}
/**
* Compares {@link UName}s by their names.
*/
public static final Comparator comparator = new Comparator() {
public int compare(Object o1, Object o2) {
UName lhs = (UName)o1;
UName rhs = (UName)o2;
int r = lhs.nsUri.compareTo(rhs.nsUri);
if(r!=0) return r;
return lhs.localName.compareTo(rhs.localName);
}
};
}

View File

@@ -0,0 +1,97 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSUnionSimpleType;
import com.sun.xml.internal.xsom.XSVariety;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor;
import org.xml.sax.Locator;
import java.util.Iterator;
import java.util.Set;
import java.util.List;
import java.util.Collections;
public class UnionSimpleTypeImpl extends SimpleTypeImpl implements XSUnionSimpleType
{
public UnionSimpleTypeImpl( SchemaDocumentImpl _parent,
AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
String _name, boolean _anonymous, Set<XSVariety> finalSet,
Ref.SimpleType[] _members ) {
super(_parent,_annon,_loc,_fa,_name,_anonymous, finalSet,
_parent.getSchema().parent.anySimpleType);
this.memberTypes = _members;
}
private final Ref.SimpleType[] memberTypes;
public XSSimpleType getMember( int idx ) { return memberTypes[idx].getType(); }
public int getMemberSize() { return memberTypes.length; }
public Iterator<XSSimpleType> iterator() {
return new Iterator<XSSimpleType>() {
int idx=0;
public boolean hasNext() {
return idx<memberTypes.length;
}
public XSSimpleType next() {
return memberTypes[idx++].getType();
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
public void visit( XSSimpleTypeVisitor visitor ) {
visitor.unionSimpleType(this);
}
public Object apply( XSSimpleTypeFunction function ) {
return function.unionSimpleType(this);
}
public XSUnionSimpleType getBaseUnionType() {
return this;
}
// union type by itself doesn't have any facet. */
public XSFacet getFacet( String name ) { return null; }
public List<XSFacet> getFacets( String name ) { return Collections.EMPTY_LIST; }
public XSVariety getVariety() { return XSVariety.UNION; }
public XSSimpleType getPrimitiveType() { return null; }
public boolean isUnion() { return true; }
public XSUnionSimpleType asUnion() { return this; }
}

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
*
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
class Util {
private static XSType[] listDirectSubstitutables( XSType _this ) {
ArrayList r = new ArrayList();
// TODO: handle @block
Iterator itr = ((SchemaImpl)_this.getOwnerSchema()).parent.iterateTypes();
while( itr.hasNext() ) {
XSType t = (XSType)itr.next();
if( t.getBaseType()==_this )
r.add(t);
}
return (XSType[]) r.toArray(new XSType[r.size()]);
}
public static XSType[] listSubstitutables( XSType _this ) {
Set substitables = new HashSet();
buildSubstitutables( _this, substitables );
return (XSType[]) substitables.toArray(new XSType[substitables.size()]);
}
public static void buildSubstitutables( XSType _this, Set substitutables ) {
if( _this.isLocal() ) return;
buildSubstitutables( _this, _this, substitutables );
}
private static void buildSubstitutables( XSType head, XSType _this, Set substitutables ) {
if(!isSubstitutable(head,_this))
return; // no derived type of _this can substitute head.
if(substitutables.add(_this)) {
XSType[] child = listDirectSubstitutables(_this);
for( int i=0; i<child.length; i++ )
buildSubstitutables( head, child[i], substitutables );
}
}
/**
* Implements
* <code>Validation Rule: Schema-Validity Assessment (Element) 1.2.1.2.4</code>
*/
private static boolean isSubstitutable( XSType _base, XSType derived ) {
// too ugly to the point that it's almost unbearable.
// I mean, it's not even transitive. Thus we end up calling this method
// for each candidate
if( _base.isComplexType() ) {
XSComplexType base = _base.asComplexType();
for( ; base!=derived; derived=derived.getBaseType() ) {
if( base.isSubstitutionProhibited( derived.getDerivationMethod() ) )
return false; // Type Derivation OK (Complex)-1
}
return true;
} else {
// simple type don't have any @block
return true;
}
}
}

View File

@@ -0,0 +1,199 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSTerm;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunction;
import com.sun.xml.internal.xsom.visitor.XSTermFunctionWithParam;
import com.sun.xml.internal.xsom.visitor.XSTermVisitor;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import com.sun.xml.internal.xsom.visitor.XSWildcardFunction;
import com.sun.xml.internal.xsom.visitor.XSWildcardVisitor;
import org.xml.sax.Locator;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public abstract class WildcardImpl extends ComponentImpl implements XSWildcard, Ref.Term
{
protected WildcardImpl( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa, int _mode ) {
super(owner,_annon,_loc,_fa);
this.mode = _mode;
}
private final int mode;
public int getMode() { return mode; }
// compute the union
public WildcardImpl union( SchemaDocumentImpl owner, WildcardImpl rhs ) {
if(this instanceof Any || rhs instanceof Any)
return new Any(owner,null,null,null,mode);
if(this instanceof Finite && rhs instanceof Finite) {
Set<String> values = new HashSet<String>();
values.addAll( ((Finite)this).names );
values.addAll( ((Finite)rhs ).names );
return new Finite(owner,null,null,null,values,mode);
}
if(this instanceof Other && rhs instanceof Other) {
if( ((Other)this).otherNamespace.equals(
((Other)rhs).otherNamespace) )
return new Other(owner,null,null,null, ((Other)this).otherNamespace, mode );
else
// this somewhat strange rule is indeed in the spec
return new Other(owner,null,null,null, "", mode );
}
Other o;
Finite f;
if( this instanceof Other ) {
o=(Other)this; f=(Finite)rhs;
} else {
o=(Other)rhs; f=(Finite)this;
}
if(f.names.contains(o.otherNamespace))
return new Any(owner,null,null,null,mode);
else
return new Other(owner,null,null,null,o.otherNamespace,mode);
}
public final static class Any extends WildcardImpl implements XSWildcard.Any {
public Any( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa, int _mode ) {
super(owner,_annon,_loc,_fa,_mode);
}
public boolean acceptsNamespace( String namespaceURI ) {
return true;
}
public void visit( XSWildcardVisitor visitor ) {
visitor.any(this);
}
public Object apply( XSWildcardFunction function ) {
return function.any(this);
}
}
public final static class Other extends WildcardImpl implements XSWildcard.Other {
public Other( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
String otherNamespace, int _mode ) {
super(owner,_annon,_loc,_fa,_mode);
this.otherNamespace = otherNamespace;
}
private final String otherNamespace;
public String getOtherNamespace() { return otherNamespace; }
public boolean acceptsNamespace( String namespaceURI ) {
return !namespaceURI.equals(otherNamespace);
}
public void visit( XSWildcardVisitor visitor ) {
visitor.other(this);
}
public Object apply( XSWildcardFunction function ) {
return function.other(this);
}
}
public final static class Finite extends WildcardImpl implements XSWildcard.Union {
public Finite( SchemaDocumentImpl owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl _fa,
Set<String> ns, int _mode ) {
super(owner,_annon,_loc,_fa,_mode);
names = ns;
namesView = Collections.unmodifiableSet(names);
}
private final Set<String> names;
private final Set<String> namesView;
public Iterator<String> iterateNamespaces() {
return names.iterator();
}
public Collection<String> getNamespaces() {
return namesView;
}
public boolean acceptsNamespace( String namespaceURI ) {
return names.contains(namespaceURI);
}
public void visit( XSWildcardVisitor visitor ) {
visitor.union(this);
}
public Object apply( XSWildcardFunction function ) {
return function.union(this);
}
}
public final void visit( XSVisitor visitor ) {
visitor.wildcard(this);
}
public final void visit( XSTermVisitor visitor ) {
visitor.wildcard(this);
}
public Object apply( XSTermFunction function ) {
return function.wildcard(this);
}
public <T,P> T apply(XSTermFunctionWithParam<T, P> function, P param) {
return function.wildcard(this,param);
}
public Object apply( XSFunction function ) {
return function.wildcard(this);
}
public boolean isWildcard() { return true; }
public boolean isModelGroupDecl() { return false; }
public boolean isModelGroup() { return false; }
public boolean isElementDecl() { return false; }
public XSWildcard asWildcard() { return this; }
public XSModelGroupDecl asModelGroupDecl() { return null; }
public XSModelGroup asModelGroup() { return null; }
public XSElementDecl asElementDecl() { return null; }
// Ref.Term implementation
public XSTerm getTerm() { return this; }
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSXPath;
import com.sun.xml.internal.xsom.XmlString;
import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import org.xml.sax.Locator;
/**
* @author Kohsuke Kawaguchi
*/
public class XPathImpl extends ComponentImpl implements XSXPath {
private XSIdentityConstraint parent;
private final XmlString xpath;
public XPathImpl(SchemaDocumentImpl _owner, AnnotationImpl _annon, Locator _loc, ForeignAttributesImpl fa, XmlString xpath) {
super(_owner, _annon, _loc, fa);
this.xpath = xpath;
}
public void setParent(XSIdentityConstraint parent) {
this.parent = parent;
}
public XSIdentityConstraint getParent() {
return parent;
}
public XmlString getXPath() {
return xpath;
}
public void visit(XSVisitor visitor) {
visitor.xpath(this);
}
public <T> T apply(XSFunction<T> function) {
return function.xpath(this);
}
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.impl.Ref;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSType;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
public final class BaseContentRef implements Ref.ContentType, Patch {
private final Ref.Type baseType;
private final Locator loc;
public BaseContentRef(final NGCCRuntimeEx $runtime, Ref.Type _baseType) {
this.baseType = _baseType;
$runtime.addPatcher(this);
$runtime.addErrorChecker(new Patch() {
public void run() throws SAXException {
XSType t = baseType.getType();
if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) {
$runtime.reportError(
Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED,
t.getTargetNamespace(), t.getName()), loc);
}
}
});
this.loc = $runtime.copyLocator();
}
public XSContentType getContentType() {
XSType t = baseType.getType();
if(t.asComplexType()!=null)
return t.asComplexType().getContentType();
else
return t.asSimpleType();
}
public void run() throws SAXException {
if (baseType instanceof Patch)
((Patch) baseType).run();
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.parser.AnnotationContext;
import com.sun.xml.internal.xsom.parser.AnnotationParser;
import org.xml.sax.ContentHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.helpers.DefaultHandler;
/**
* AnnotationParser that just ignores annotation.
*
* <p>
* This class doesn't have any state. So it should be used as a singleton.
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
class DefaultAnnotationParser extends AnnotationParser {
private DefaultAnnotationParser() {}
public static final AnnotationParser theInstance = new DefaultAnnotationParser();
public ContentHandler getContentHandler(
AnnotationContext contest, String elementName,
ErrorHandler errorHandler, EntityResolver entityResolver ) {
return new DefaultHandler();
}
public Object getResult( Object existing ) {
return null;
}
}

View File

@@ -0,0 +1,256 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSDeclaration;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSSchemaSet;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSTerm;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.impl.Ref;
import com.sun.xml.internal.xsom.impl.SchemaImpl;
import com.sun.xml.internal.xsom.impl.UName;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
/**
* Reference by name.
*
* UName will be later resolved to a target object,
* after all the schemas are parsed.
*/
public abstract class DelayedRef implements Patch {
DelayedRef( PatcherManager _manager, Locator _source, SchemaImpl _schema, UName _name ) {
this.schema = _schema.getRoot();
this.manager = _manager;
this.name = _name;
this.source = _source;
if(name==null) throw new InternalError();
manager.addPatcher(this);
}
/**
* Patch implementation. Makes sure that the name resolves
* to a schema component.
*/
public void run() throws SAXException {
if(ref==null) // redefinition can set ref without actually resolving the reference
resolve();
manager = null; // avoid keeping the reference too long
name = null;
source = null;
}
protected final XSSchemaSet schema;
private PatcherManager manager;
private UName name;
/** location in the source file where this reference was made. */
private Locator source;
protected abstract Object resolveReference( UName name );
protected abstract String getErrorProperty();
private Object ref=null;
protected final Object _get() {
if(ref==null) throw new InternalError("unresolved reference");
return ref;
}
private void resolve() throws SAXException {
ref = resolveReference(name);
if(ref==null)
manager.reportError(
Messages.format(getErrorProperty(),name.getQualifiedName()),
source );
}
/**
* If this reference refers to the given declaration,
* resolve the reference now. This is used to implement redefinition.
*/
public void redefine(XSDeclaration d) {
if( !d.getTargetNamespace().equals(name.getNamespaceURI())
|| !d.getName().equals(name.getName()) )
return;
ref = d;
manager = null;
name = null;
source = null;
}
public static class Type extends DelayedRef implements Ref.Type {
public Type( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
protected Object resolveReference( UName name ) {
Object o = super.schema.getSimpleType(
name.getNamespaceURI(), name.getName() );
if(o!=null) return o;
return super.schema.getComplexType(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_TYPE;
}
public XSType getType() { return (XSType)super._get(); }
}
public static class SimpleType extends DelayedRef implements Ref.SimpleType {
public SimpleType( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
public XSSimpleType getType() { return (XSSimpleType)_get(); }
protected Object resolveReference( UName name ) {
return super.schema.getSimpleType(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_SIMPLETYPE;
}
}
public static class ComplexType extends DelayedRef implements Ref.ComplexType {
public ComplexType( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
protected Object resolveReference( UName name ) {
return super.schema.getComplexType(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_COMPLEXTYPE;
}
public XSComplexType getType() { return (XSComplexType)super._get(); }
}
public static class Element extends DelayedRef implements Ref.Element {
public Element( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
protected Object resolveReference( UName name ) {
return super.schema.getElementDecl(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_ELEMENT;
}
public XSElementDecl get() { return (XSElementDecl)super._get(); }
public XSTerm getTerm() { return get(); }
}
public static class ModelGroup extends DelayedRef implements Ref.Term {
public ModelGroup( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
protected Object resolveReference( UName name ) {
return super.schema.getModelGroupDecl(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_MODELGROUP;
}
public XSModelGroupDecl get() { return (XSModelGroupDecl)super._get(); }
public XSTerm getTerm() { return get(); }
}
public static class AttGroup extends DelayedRef implements Ref.AttGroup {
public AttGroup( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
protected Object resolveReference( UName name ) {
return super.schema.getAttGroupDecl(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_ATTRIBUTEGROUP;
}
public XSAttGroupDecl get() { return (XSAttGroupDecl)super._get(); }
}
public static class Attribute extends DelayedRef implements Ref.Attribute {
public Attribute( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
protected Object resolveReference( UName name ) {
return super.schema.getAttributeDecl(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_ATTRIBUTE;
}
public XSAttributeDecl getAttribute() { return (XSAttributeDecl)super._get(); }
}
public static class IdentityConstraint extends DelayedRef implements Ref.IdentityConstraint {
public IdentityConstraint( PatcherManager manager, Locator loc, SchemaImpl schema, UName name ) {
super(manager,loc,schema,name);
}
protected Object resolveReference( UName name ) {
return super.schema.getIdentityConstraint(
name.getNamespaceURI(),
name.getName());
}
protected String getErrorProperty() {
return Messages.ERR_UNDEFINED_IDENTITY_CONSTRAINT;
}
public XSIdentityConstraint get() { return (XSIdentityConstraint)super._get(); }
}
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import java.text.MessageFormat;
import java.util.ResourceBundle;
/**
* Formats error messages.
*/
public class Messages
{
/** Loads a string resource and formats it with specified arguments. */
public static String format( String property, Object... args ) {
String text = ResourceBundle.getBundle(
Messages.class.getName()).getString(property);
return MessageFormat.format(text,args);
}
//
//
// Message resources
//
//
public static final String ERR_UNDEFINED_SIMPLETYPE =
"UndefinedSimpleType"; // arg:1
public static final String ERR_UNDEFINED_COMPLEXTYPE =
"UndefinedCompplexType"; // arg:1
public static final String ERR_UNDEFINED_TYPE =
"UndefinedType"; // arg:1
public static final String ERR_UNDEFINED_ELEMENT =
"UndefinedElement"; // arg:1
public static final String ERR_UNDEFINED_MODELGROUP =
"UndefinedModelGroup"; // arg:1
public static final String ERR_UNDEFINED_ATTRIBUTE =
"UndefinedAttribute"; // arg:1
public static final String ERR_UNDEFINED_ATTRIBUTEGROUP =
"UndefinedAttributeGroup"; // arg:1
public static final String ERR_UNDEFINED_IDENTITY_CONSTRAINT =
"UndefinedIdentityConstraint"; // arg:1
public static final String ERR_UNDEFINED_PREFIX =
"UndefinedPrefix"; // arg:1
public static final String ERR_DOUBLE_DEFINITION =
"DoubleDefinition"; // arg:1
public static final String ERR_DOUBLE_DEFINITION_ORIGINAL =
"DoubleDefinition.Original"; // arg:0
public static final String ERR_MISSING_SCHEMALOCATION =
"MissingSchemaLocation"; // arg:0
public static final String ERR_ENTITY_RESOLUTION_FAILURE =
"EntityResolutionFailure"; // arg:2
public static final String ERR_SIMPLE_CONTENT_EXPECTED =
"SimpleContentExpected"; // arg:2
public static final String JAXP_UNSUPPORTED_PROPERTY =
"JAXPUnsupportedProperty"; // arg:1
public static final String JAXP_SUPPORTED_PROPERTY =
"JAXPSupportedProperty"; // arg:1
}

View File

@@ -0,0 +1,516 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.XSDeclaration;
import com.sun.xml.internal.xsom.XmlString;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.impl.ForeignAttributesImpl;
import com.sun.xml.internal.xsom.impl.SchemaImpl;
import com.sun.xml.internal.xsom.impl.UName;
import com.sun.xml.internal.xsom.impl.Const;
import com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime;
import com.sun.xml.internal.xsom.impl.parser.state.Schema;
import com.sun.xml.internal.xsom.impl.util.Uri;
import com.sun.xml.internal.xsom.parser.AnnotationParser;
import org.relaxng.datatype.ValidationContext;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.LocatorImpl;
import java.io.IOException;
import java.net.URI;
import java.text.MessageFormat;
import java.util.Stack;
/**
* NGCCRuntime extended with various utility methods for
* parsing XML Schema.
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public class NGCCRuntimeEx extends NGCCRuntime implements PatcherManager {
/** coordinator. */
public final ParserContext parser;
/** The schema currently being parsed. */
public SchemaImpl currentSchema;
/** The @finalDefault value of the current schema. */
public int finalDefault = 0;
/** The @blockDefault value of the current schema. */
public int blockDefault = 0;
/**
* The @elementFormDefault value of the current schema.
* True if local elements are qualified by default.
*/
public boolean elementFormDefault = false;
/**
* The @attributeFormDefault value of the current schema.
* True if local attributes are qualified by default.
*/
public boolean attributeFormDefault = false;
/**
* True if the current schema is in a chameleon mode.
* This changes the way QNames are interpreted.
*
* Life is very miserable with XML Schema, as you see.
*/
public boolean chameleonMode = false;
/**
* URI that identifies the schema document.
* Maybe null if the system ID is not available.
*/
private String documentSystemId;
/**
* Keep the local name of elements encountered so far.
* This information is passed to AnnotationParser as
* context information
*/
private final Stack<String> elementNames = new Stack<String>();
/**
* Points to the schema document (the parser of it) that included/imported
* this schema.
*/
private final NGCCRuntimeEx referer;
/**
* Points to the {@link SchemaDocumentImpl} that represents the
* schema document being parsed.
*/
public SchemaDocumentImpl document;
NGCCRuntimeEx( ParserContext _parser ) {
this(_parser,false,null);
}
private NGCCRuntimeEx( ParserContext _parser, boolean chameleonMode, NGCCRuntimeEx referer ) {
this.parser = _parser;
this.chameleonMode = chameleonMode;
this.referer = referer;
// set up the default namespace binding
currentContext = new Context("","",null);
currentContext = new Context("xml","http://www.w3.org/XML/1998/namespace",currentContext);
}
public void checkDoubleDefError( XSDeclaration c ) throws SAXException {
if(c==null || ignorableDuplicateComponent(c)) return;
reportError( Messages.format(Messages.ERR_DOUBLE_DEFINITION,c.getName()) );
reportError( Messages.format(Messages.ERR_DOUBLE_DEFINITION_ORIGINAL), c.getLocator() );
}
public static boolean ignorableDuplicateComponent(XSDeclaration c) {
if(c.getTargetNamespace().equals(Const.schemaNamespace)) {
if(c instanceof XSSimpleType)
// hide artificial "double definitions" on simple types
return true;
if(c.isGlobal() && c.getName().equals("anyType"))
return true; // ditto for anyType
}
return false;
}
/* registers a patcher that will run after all the parsing has finished. */
public void addPatcher( Patch patcher ) {
parser.patcherManager.addPatcher(patcher);
}
public void addErrorChecker( Patch patcher ) {
parser.patcherManager.addErrorChecker(patcher);
}
public void reportError( String msg, Locator loc ) throws SAXException {
parser.patcherManager.reportError(msg,loc);
}
public void reportError( String msg ) throws SAXException {
reportError(msg,getLocator());
}
/**
* Resolves relative URI found in the document.
*
* @param namespaceURI
* passed to the entity resolver.
* @param relativeUri
* value of the schemaLocation attribute. Can be null.
*
* @return
* non-null if {@link EntityResolver} returned an {@link InputSource},
* or if the relativeUri parameter seems to be pointing to something.
* Otherwise it returns null, in which case import/include should be abandoned.
*/
private InputSource resolveRelativeURL( String namespaceURI, String relativeUri ) throws SAXException {
try {
String baseUri = getLocator().getSystemId();
if(baseUri==null)
// if the base URI is not available, the document system ID is
// better than nothing.
baseUri=documentSystemId;
EntityResolver er = parser.getEntityResolver();
String systemId = null;
if (relativeUri!=null)
systemId = Uri.resolve(baseUri,relativeUri);
if (er!=null) {
InputSource is = er.resolveEntity(namespaceURI,systemId);
if (is == null) {
try {
String normalizedSystemId = URI.create(systemId).normalize().toASCIIString();
is = er.resolveEntity(namespaceURI,normalizedSystemId);
} catch (Exception e) {
// just ignore, this is a second try, return the fallback if this breaks
}
}
if (is != null) {
return is;
}
}
if (systemId!=null)
return new InputSource(systemId);
else
return null;
} catch (IOException e) {
SAXParseException se = new SAXParseException(e.getMessage(),getLocator(),e);
parser.errorHandler.error(se);
return null;
}
}
/** Includes the specified schema. */
public void includeSchema( String schemaLocation ) throws SAXException {
NGCCRuntimeEx runtime = new NGCCRuntimeEx(parser,chameleonMode,this);
runtime.currentSchema = this.currentSchema;
runtime.blockDefault = this.blockDefault;
runtime.finalDefault = this.finalDefault;
if( schemaLocation==null ) {
SAXParseException e = new SAXParseException(
Messages.format( Messages.ERR_MISSING_SCHEMALOCATION ), getLocator() );
parser.errorHandler.fatalError(e);
throw e;
}
runtime.parseEntity( resolveRelativeURL(null,schemaLocation),
true, currentSchema.getTargetNamespace(), getLocator() );
}
/** Imports the specified schema. */
public void importSchema( String ns, String schemaLocation ) throws SAXException {
NGCCRuntimeEx newRuntime = new NGCCRuntimeEx(parser,false,this);
InputSource source = resolveRelativeURL(ns,schemaLocation);
if(source!=null)
newRuntime.parseEntity( source, false, ns, getLocator() );
// if source == null,
// we can't locate this document. Let's just hope that
// we already have the schema components for this schema
// or we will receive them in the future.
}
/**
* Called when a new document is being parsed and checks
* if the document has already been parsed before.
*
* <p>
* Used to avoid recursive inclusion. Note that the same
* document will be parsed multiple times if they are for different
* target namespaces.
*
* <h2>Document Graph Model</h2>
* <p>
* The challenge we are facing here is that you have a graph of
* documents that reference each other. Each document has an unique
* URI to identify themselves, and references are done by using those.
* The graph may contain cycles.
*
* <p>
* Our goal here is to parse all the documents in the graph, without
* parsing the same document twice. This method implements this check.
*
* <p>
* One complication is the chameleon schema; a document can be parsed
* multiple times if they are under different target namespaces.
*
* <p>
* Also, note that when you resolve relative URIs in the @schemaLocation,
* their base URI is *NOT* the URI of the document.
*
* @return true if the document has already been processed and thus
* needs to be skipped.
*/
public boolean hasAlreadyBeenRead() {
if( documentSystemId!=null ) {
if( documentSystemId.startsWith("file:///") )
// change file:///abc to file:/abc
// JDK File.toURL method produces the latter, but according to RFC
// I don't think that's a valid URL. Since two different ways of
// producing URLs could produce those two different forms,
// we need to canonicalize one to the other.
documentSystemId = "file:/"+documentSystemId.substring(8);
} else {
// if the system Id is not provided, we can't test the identity,
// so we have no choice but to read it.
// the newly created SchemaDocumentImpl will be unique one
}
assert document ==null;
document = new SchemaDocumentImpl( currentSchema, documentSystemId );
SchemaDocumentImpl existing = parser.parsedDocuments.get(document);
if(existing==null) {
parser.parsedDocuments.put(document,document);
} else {
document = existing;
}
assert document !=null;
if(referer!=null) {
assert referer.document !=null : "referer "+referer.documentSystemId+" has docIdentity==null";
referer.document.references.add(this.document);
this.document.referers.add(referer.document);
}
return existing!=null;
}
/**
* Parses the specified entity.
*
* @param importLocation
* The source location of the import/include statement.
* Used for reporting errors.
*/
public void parseEntity( InputSource source, boolean includeMode, String expectedNamespace, Locator importLocation )
throws SAXException {
documentSystemId = source.getSystemId();
try {
Schema s = new Schema(this,includeMode,expectedNamespace);
setRootHandler(s);
try {
parser.parser.parse(source,this, getErrorHandler(), parser.getEntityResolver());
} catch( IOException fnfe ) {
SAXParseException se = new SAXParseException(fnfe.toString(), importLocation, fnfe);
parser.errorHandler.warning(se);
}
} catch( SAXException e ) {
parser.setErrorFlag();
throw e;
}
}
/**
* Creates a new instance of annotation parser.
*/
public AnnotationParser createAnnotationParser() {
if(parser.getAnnotationParserFactory()==null)
return DefaultAnnotationParser.theInstance;
else
return parser.getAnnotationParserFactory().create();
}
/**
* Gets the element name that contains the annotation element.
* This method works correctly only when called by the annotation handler.
*/
public String getAnnotationContextElementName() {
return elementNames.get( elementNames.size()-2 );
}
/** Creates a copy of the current locator object. */
public Locator copyLocator() {
return new LocatorImpl(getLocator());
}
public ErrorHandler getErrorHandler() {
return parser.errorHandler;
}
@Override
public void onEnterElementConsumed(String uri, String localName, String qname, Attributes atts)
throws SAXException {
super.onEnterElementConsumed(uri, localName, qname, atts);
elementNames.push(localName);
}
@Override
public void onLeaveElementConsumed(String uri, String localName, String qname) throws SAXException {
super.onLeaveElementConsumed(uri, localName, qname);
elementNames.pop();
}
//
//
// ValidationContext implementation
//
//
// this object lives longer than the parser itself,
// so it's important for this object not to have any reference
// to the parser.
private static class Context implements ValidationContext {
Context( String _prefix, String _uri, Context _context ) {
this.previous = _context;
this.prefix = _prefix;
this.uri = _uri;
}
public String resolveNamespacePrefix(String p) {
if(p.equals(prefix)) return uri;
if(previous==null) return null;
else return previous.resolveNamespacePrefix(p);
}
private final String prefix;
private final String uri;
private final Context previous;
// XSDLib don't use those methods, so we cut a corner here.
public String getBaseUri() { return null; }
public boolean isNotation(String arg0) { return false; }
public boolean isUnparsedEntity(String arg0) { return false; }
}
private Context currentContext=null;
/** Returns an immutable snapshot of the current context. */
public ValidationContext createValidationContext() {
return currentContext;
}
public XmlString createXmlString(String value) {
if(value==null) return null;
else return new XmlString(value,createValidationContext());
}
@Override
public void startPrefixMapping( String prefix, String uri ) throws SAXException {
super.startPrefixMapping(prefix,uri);
currentContext = new Context(prefix,uri,currentContext);
}
@Override
public void endPrefixMapping( String prefix ) throws SAXException {
super.endPrefixMapping(prefix);
currentContext = currentContext.previous;
}
//
//
// Utility functions
//
//
/** Parses UName under the given context. */
public UName parseUName( String qname ) throws SAXException {
int idx = qname.indexOf(':');
if(idx<0) {
String uri = resolveNamespacePrefix("");
// chamelon behavior. ugly...
if( uri.equals("") && chameleonMode )
uri = currentSchema.getTargetNamespace();
// this is guaranteed to resolve
return new UName(uri,qname,qname);
} else {
String prefix = qname.substring(0,idx);
String uri = currentContext.resolveNamespacePrefix(prefix);
if(uri==null) {
// prefix failed to resolve.
reportError(Messages.format(
Messages.ERR_UNDEFINED_PREFIX,prefix));
uri="undefined"; // replace with a dummy
}
return new UName( uri, qname.substring(idx+1), qname );
}
}
public boolean parseBoolean(String v) {
if(v==null) return false;
v=v.trim();
return v.equals("true") || v.equals("1");
}
@Override
protected void unexpectedX(String token) throws SAXException {
SAXParseException e = new SAXParseException(MessageFormat.format(
"Unexpected {0} appears at line {1} column {2}",
token,
getLocator().getLineNumber(),
getLocator().getColumnNumber()),
getLocator());
parser.errorHandler.fatalError(e);
throw e; // we will abort anyway
}
public ForeignAttributesImpl parseForeignAttributes( ForeignAttributesImpl next ) {
ForeignAttributesImpl impl = new ForeignAttributesImpl(createValidationContext(),copyLocator(),next);
Attributes atts = getCurrentAttributes();
for( int i=0; i<atts.getLength(); i++ ) {
if(atts.getURI(i).length()>0) {
impl.addAttribute(
atts.getURI(i),
atts.getLocalName(i),
atts.getQName(i),
atts.getType(i),
atts.getValue(i)
);
}
}
return impl;
}
public static final String XMLSchemaNSURI = "http://www.w3.org/2001/XMLSchema";
}

View File

@@ -0,0 +1,212 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.XSSchemaSet;
import com.sun.xml.internal.xsom.impl.ElementDecl;
import com.sun.xml.internal.xsom.impl.SchemaImpl;
import com.sun.xml.internal.xsom.impl.SchemaSetImpl;
import com.sun.xml.internal.xsom.parser.AnnotationParserFactory;
import com.sun.xml.internal.xsom.parser.XMLParser;
import com.sun.xml.internal.xsom.parser.XSOMParser;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
/**
* Provides context information to be used by {@link NGCCRuntimeEx}s.
*
* <p>
* This class does the actual processing for {@link XSOMParser},
* but to hide the details from the public API, this class in
* a different package.
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public class ParserContext {
/** SchemaSet to which a newly parsed schema is put in. */
public final SchemaSetImpl schemaSet = new SchemaSetImpl();
private final XSOMParser owner;
final XMLParser parser;
private final Vector<Patch> patchers = new Vector<Patch>();
private final Vector<Patch> errorCheckers = new Vector<Patch>();
/**
* Documents that are parsed already. Used to avoid cyclic inclusion/double
* inclusion of schemas. Set of {@link SchemaDocumentImpl}s.
*
* The actual data structure is map from {@link SchemaDocumentImpl} to itself,
* so that we can access the {@link SchemaDocumentImpl} itself.
*/
public final Map<SchemaDocumentImpl, SchemaDocumentImpl> parsedDocuments = new HashMap<SchemaDocumentImpl, SchemaDocumentImpl>();
public ParserContext( XSOMParser owner, XMLParser parser ) {
this.owner = owner;
this.parser = parser;
try {
parse(new InputSource(ParserContext.class.getResource("datatypes.xsd").toExternalForm()));
SchemaImpl xs = (SchemaImpl)
schemaSet.getSchema("http://www.w3.org/2001/XMLSchema");
xs.addSimpleType(schemaSet.anySimpleType,true);
xs.addComplexType(schemaSet.anyType,true);
} catch( SAXException e ) {
// this must be a bug of XSOM
if(e.getException()!=null)
e.getException().printStackTrace();
else
e.printStackTrace();
throw new InternalError();
}
}
public EntityResolver getEntityResolver() {
return owner.getEntityResolver();
}
public AnnotationParserFactory getAnnotationParserFactory() {
return owner.getAnnotationParserFactory();
}
/**
* Parses a new XML Schema document.
*/
public void parse( InputSource source ) throws SAXException {
newNGCCRuntime().parseEntity(source,false,null,null);
}
public XSSchemaSet getResult() throws SAXException {
// run all the patchers
for (Patch patcher : patchers)
patcher.run();
patchers.clear();
// build the element substitutability map
Iterator itr = schemaSet.iterateElementDecls();
while(itr.hasNext())
((ElementDecl)itr.next()).updateSubstitutabilityMap();
// run all the error checkers
for (Patch patcher : errorCheckers)
patcher.run();
errorCheckers.clear();
if(hadError) return null;
else return schemaSet;
}
public NGCCRuntimeEx newNGCCRuntime() {
return new NGCCRuntimeEx(this);
}
/** Once an error is detected, this flag is set to true. */
private boolean hadError = false;
/** Turns on the error flag. */
void setErrorFlag() { hadError=true; }
/**
* PatchManager implementation, which is accessible only from
* NGCCRuntimEx.
*/
final PatcherManager patcherManager = new PatcherManager() {
public void addPatcher( Patch patch ) {
patchers.add(patch);
}
public void addErrorChecker( Patch patch ) {
errorCheckers.add(patch);
}
public void reportError( String msg, Locator src ) throws SAXException {
// set a flag to true to avoid returning a corrupted object.
setErrorFlag();
SAXParseException e = new SAXParseException(msg,src);
if(errorHandler==null)
throw e;
else
errorHandler.error(e);
}
};
/**
* ErrorHandler proxy to turn on the hadError flag when an error
* is found.
*/
final ErrorHandler errorHandler = new ErrorHandler() {
private ErrorHandler getErrorHandler() {
if( owner.getErrorHandler()==null )
return noopHandler;
else
return owner.getErrorHandler();
}
public void warning(SAXParseException e) throws SAXException {
getErrorHandler().warning(e);
}
public void error(SAXParseException e) throws SAXException {
setErrorFlag();
getErrorHandler().error(e);
}
public void fatalError(SAXParseException e) throws SAXException {
setErrorFlag();
getErrorHandler().fatalError(e);
}
};
/**
* {@link ErrorHandler} that does nothing.
*/
final ErrorHandler noopHandler = new ErrorHandler() {
public void warning(SAXParseException e) {
}
public void error(SAXParseException e) {
}
public void fatalError(SAXParseException e) {
setErrorFlag();
}
};
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import org.xml.sax.SAXException;
/**
* Patch program that runs later to "fix" references among components.
*
* The only difference from the Runnable interface is that this interface
* allows the program to throw a SAXException.
*/
public interface Patch {
void run() throws SAXException;
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
/**
* Manages patchers.
*
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public interface PatcherManager {
void addPatcher( Patch p );
void addErrorChecker( Patch p );
/**
* Reports an error during the parsing.
*
* @param source
* location of the error in the source file, or null if
* it's unavailable.
*/
void reportError( String message, Locator source ) throws SAXException;
public interface Patcher {
void run() throws SAXException;
}
}

View File

@@ -0,0 +1,111 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.parser.XMLParser;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl;
import org.xml.sax.helpers.XMLReaderAdapter;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.io.IOException;
/**
* {@link SAXParserFactory} implementation that ultimately
* uses {@link XMLParser} to parse documents.
*
* @deprecated
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public class SAXParserFactoryAdaptor extends SAXParserFactory {
private final XMLParser parser;
public SAXParserFactoryAdaptor( XMLParser _parser ) {
this.parser = _parser;
}
public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
return new SAXParserImpl();
}
public void setFeature(String name, boolean value) {
throw new UnsupportedOperationException("XSOM parser does not support JAXP features.");
}
public boolean getFeature(String name) {
return false;
}
private class SAXParserImpl extends SAXParser
{
private final XMLReaderImpl reader = new XMLReaderImpl();
/**
* @deprecated
*/
public org.xml.sax.Parser getParser() throws SAXException {
return new XMLReaderAdapter(reader);
}
public XMLReader getXMLReader() throws SAXException {
return reader;
}
public boolean isNamespaceAware() {
return true;
}
public boolean isValidating() {
return false;
}
public void setProperty(String name, Object value) {
}
public Object getProperty(String name) {
return null;
}
}
private class XMLReaderImpl extends XMLFilterImpl
{
public void parse(InputSource input) throws IOException, SAXException {
parser.parse(input,this,this,this);
}
public void parse(String systemId) throws IOException, SAXException {
parser.parse(new InputSource(systemId),this,this,this);
}
}
}

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.impl.SchemaImpl;
import com.sun.xml.internal.xsom.parser.SchemaDocument;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* {@link SchemaDocument} implementation.
*
* @author Kohsuke Kawaguchi
*/
public final class SchemaDocumentImpl implements SchemaDocument
{
private final SchemaImpl schema;
/**
* URI of the schema document to be parsed. Can be null.
*/
private final String schemaDocumentURI;
/**
* {@link SchemaDocumentImpl}s that are referenced from this document.
*/
final Set<SchemaDocumentImpl> references = new HashSet<SchemaDocumentImpl>();
/**
* {@link SchemaDocumentImpl}s that are referencing this document.
*/
final Set<SchemaDocumentImpl> referers = new HashSet<SchemaDocumentImpl>();
protected SchemaDocumentImpl(SchemaImpl schema, String _schemaDocumentURI) {
this.schema = schema;
this.schemaDocumentURI = _schemaDocumentURI;
}
public String getSystemId() {
return schemaDocumentURI;
}
public String getTargetNamespace() {
return schema.getTargetNamespace();
}
public SchemaImpl getSchema() {
return schema;
}
public Set<SchemaDocument> getReferencedDocuments() {
return Collections.<SchemaDocument>unmodifiableSet(references);
}
public Set<SchemaDocument> getIncludedDocuments() {
return getImportedDocuments(this.getTargetNamespace());
}
public Set<SchemaDocument> getImportedDocuments(String targetNamespace) {
if(targetNamespace==null)
throw new IllegalArgumentException();
Set<SchemaDocument> r = new HashSet<SchemaDocument>();
for (SchemaDocumentImpl doc : references) {
if(doc.getTargetNamespace().equals(targetNamespace))
r.add(doc);
}
return Collections.unmodifiableSet(r);
}
public boolean includes(SchemaDocument doc) {
if(!references.contains(doc))
return false;
return doc.getSchema()==schema;
}
public boolean imports(SchemaDocument doc) {
if(!references.contains(doc))
return false;
return doc.getSchema()!=schema;
}
public Set<SchemaDocument> getReferers() {
return Collections.<SchemaDocument>unmodifiableSet(referers);
}
@Override
public boolean equals(Object o) {
SchemaDocumentImpl rhs = (SchemaDocumentImpl) o;
if( this.schemaDocumentURI==null || rhs.schemaDocumentURI==null)
return this==rhs;
if(!schemaDocumentURI.equals(rhs.schemaDocumentURI) )
return false;
return this.schema==rhs.schema;
}
@Override
public int hashCode() {
if (schemaDocumentURI==null)
return super.hashCode();
if (schema == null) {
return schemaDocumentURI.hashCode();
}
return schemaDocumentURI.hashCode()^this.schema.hashCode();
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.impl.Ref;
/**
*
*
* @author
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
public class SubstGroupBaseTypeRef implements Ref.Type {
private final Ref.Element e;
public SubstGroupBaseTypeRef( Ref.Element _e ) {
this.e = _e;
}
public XSType getType() {
return e.get().getType();
}
}

View File

@@ -0,0 +1,626 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// AttributesImpl.java - default implementation of Attributes.
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
// $Id: AttributesImpl.java,v 1.4 2002/09/29 02:55:48 okajima Exp $
//fixed bug at removeAttribute!! by Daisuke OKAJIMA 2002.4.21
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.Attributes;
/**
* Default implementation of the Attributes interface.
*
* <blockquote>
* <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* </blockquote>
*
* <p>This class provides a default implementation of the SAX2
* {@link org.xml.sax.Attributes Attributes} interface, with the
* addition of manipulators so that the list can be modified or
* reused.</p>
*
* <p>There are two typical uses of this class:</p>
*
* <ol>
* <li>to take a persistent snapshot of an Attributes object
* in a {@link org.xml.sax.ContentHandler#startElement startElement} event; or</li>
* <li>to construct or modify an Attributes object in a SAX2 driver or filter.</li>
* </ol>
*
* <p>This class replaces the now-deprecated SAX1 {@link
* org.xml.sax.helpers.AttributeListImpl AttributeListImpl}
* class; in addition to supporting the updated Attributes
* interface rather than the deprecated {@link org.xml.sax.AttributeList
* AttributeList} interface, it also includes a much more efficient
* implementation using a single array rather than a set of Vectors.</p>
*
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
* @version 2.0
*/
public class AttributesImpl implements Attributes
{
////////////////////////////////////////////////////////////////////
// Constructors.
////////////////////////////////////////////////////////////////////
/**
* Construct a new, empty AttributesImpl object.
*/
public AttributesImpl ()
{
length = 0;
data = null;
}
/**
* Copy an existing Attributes object.
*
* <p>This constructor is especially useful inside a
* {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
*
* @param atts The existing Attributes object.
*/
public AttributesImpl (Attributes atts)
{
setAttributes(atts);
}
////////////////////////////////////////////////////////////////////
// Implementation of org.xml.sax.Attributes.
////////////////////////////////////////////////////////////////////
/**
* Return the number of attributes in the list.
*
* @return The number of attributes in the list.
* @see org.xml.sax.Attributes#getLength
*/
public int getLength ()
{
return length;
}
/**
* Return an attribute's Namespace URI.
*
* @param index The attribute's index (zero-based).
* @return The Namespace URI, the empty string if none is
* available, or null if the index is out of range.
* @see org.xml.sax.Attributes#getURI
*/
public String getURI (int index)
{
if (index >= 0 && index < length) {
return data[index*5];
} else {
return null;
}
}
/**
* Return an attribute's local name.
*
* @param index The attribute's index (zero-based).
* @return The attribute's local name, the empty string if
* none is available, or null if the index if out of range.
* @see org.xml.sax.Attributes#getLocalName
*/
public String getLocalName (int index)
{
if (index >= 0 && index < length) {
return data[index*5+1];
} else {
return null;
}
}
/**
* Return an attribute's qualified (prefixed) name.
*
* @param index The attribute's index (zero-based).
* @return The attribute's qualified name, the empty string if
* none is available, or null if the index is out of bounds.
* @see org.xml.sax.Attributes#getQName
*/
public String getQName (int index)
{
if (index >= 0 && index < length) {
return data[index*5+2];
} else {
return null;
}
}
/**
* Return an attribute's type by index.
*
* @param index The attribute's index (zero-based).
* @return The attribute's type, "CDATA" if the type is unknown, or null
* if the index is out of bounds.
* @see org.xml.sax.Attributes#getType(int)
*/
public String getType (int index)
{
if (index >= 0 && index < length) {
return data[index*5+3];
} else {
return null;
}
}
/**
* Return an attribute's value by index.
*
* @param index The attribute's index (zero-based).
* @return The attribute's value or null if the index is out of bounds.
* @see org.xml.sax.Attributes#getValue(int)
*/
public String getValue (int index)
{
if (index >= 0 && index < length) {
return data[index*5+4];
} else {
return null;
}
}
/**
* Look up an attribute's index by Namespace name.
*
* <p>In many cases, it will be more efficient to look up the name once and
* use the index query methods rather than using the name query methods
* repeatedly.</p>
*
* @param uri The attribute's Namespace URI, or the empty
* string if none is available.
* @param localName The attribute's local name.
* @return The attribute's index, or -1 if none matches.
* @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String)
*/
public int getIndex (String uri, String localName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
if (data[i].equals(uri) && data[i+1].equals(localName)) {
return i / 5;
}
}
return -1;
}
/**
* Look up an attribute's index by qualified (prefixed) name.
*
* @param qName The qualified name.
* @return The attribute's index, or -1 if none matches.
* @see org.xml.sax.Attributes#getIndex(java.lang.String)
*/
public int getIndex (String qName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
if (data[i+2].equals(qName)) {
return i / 5;
}
}
return -1;
}
/**
* Look up an attribute's type by Namespace-qualified name.
*
* @param uri The Namespace URI, or the empty string for a name
* with no explicit Namespace URI.
* @param localName The local name.
* @return The attribute's type, or null if there is no
* matching attribute.
* @see org.xml.sax.Attributes#getType(java.lang.String,java.lang.String)
*/
public String getType (String uri, String localName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
if (data[i].equals(uri) && data[i+1].equals(localName)) {
return data[i+3];
}
}
return null;
}
/**
* Look up an attribute's type by qualified (prefixed) name.
*
* @param qName The qualified name.
* @return The attribute's type, or null if there is no
* matching attribute.
* @see org.xml.sax.Attributes#getType(java.lang.String)
*/
public String getType (String qName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
if (data[i+2].equals(qName)) {
return data[i+3];
}
}
return null;
}
/**
* Look up an attribute's value by Namespace-qualified name.
*
* @param uri The Namespace URI, or the empty string for a name
* with no explicit Namespace URI.
* @param localName The local name.
* @return The attribute's value, or null if there is no
* matching attribute.
* @see org.xml.sax.Attributes#getValue(java.lang.String,java.lang.String)
*/
public String getValue (String uri, String localName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
if (data[i].equals(uri) && data[i+1].equals(localName)) {
return data[i+4];
}
}
return null;
}
/**
* Look up an attribute's value by qualified (prefixed) name.
*
* @param qName The qualified name.
* @return The attribute's value, or null if there is no
* matching attribute.
* @see org.xml.sax.Attributes#getValue(java.lang.String)
*/
public String getValue (String qName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
if (data[i+2].equals(qName)) {
return data[i+4];
}
}
return null;
}
////////////////////////////////////////////////////////////////////
// Manipulators.
////////////////////////////////////////////////////////////////////
/**
* Clear the attribute list for reuse.
*
* <p>Note that no memory is actually freed by this call:
* the current arrays are kept so that they can be
* reused.</p>
*/
public void clear ()
{
length = 0;
}
/**
* Copy an entire Attributes object.
*
* <p>It may be more efficient to reuse an existing object
* rather than constantly allocating new ones.</p>
*
* @param atts The attributes to copy.
*/
public void setAttributes (Attributes atts)
{
clear();
length = atts.getLength();
data = new String[length*5];
for (int i = 0; i < length; i++) {
data[i*5] = atts.getURI(i);
data[i*5+1] = atts.getLocalName(i);
data[i*5+2] = atts.getQName(i);
data[i*5+3] = atts.getType(i);
data[i*5+4] = atts.getValue(i);
}
}
/**
* Add an attribute to the end of the list.
*
* <p>For the sake of speed, this method does no checking
* to see if the attribute is already in the list: that is
* the responsibility of the application.</p>
*
* @param uri The Namespace URI, or the empty string if
* none is available or Namespace processing is not
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
* @param qName The qualified (prefixed) name, or the empty string
* if qualified names are not available.
* @param type The attribute type as a string.
* @param value The attribute value.
*/
public void addAttribute (String uri, String localName, String qName,
String type, String value)
{
ensureCapacity(length+1);
data[length*5] = uri;
data[length*5+1] = localName;
data[length*5+2] = qName;
data[length*5+3] = type;
data[length*5+4] = value;
length++;
}
/**
* Set an attribute in the list.
*
* <p>For the sake of speed, this method does no checking
* for name conflicts or well-formedness: such checks are the
* responsibility of the application.</p>
*
* @param index The index of the attribute (zero-based).
* @param uri The Namespace URI, or the empty string if
* none is available or Namespace processing is not
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
* @param qName The qualified name, or the empty string
* if qualified names are not available.
* @param type The attribute type as a string.
* @param value The attribute value.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
public void setAttribute (int index, String uri, String localName,
String qName, String type, String value)
{
if (index >= 0 && index < length) {
data[index*5] = uri;
data[index*5+1] = localName;
data[index*5+2] = qName;
data[index*5+3] = type;
data[index*5+4] = value;
} else {
badIndex(index);
}
}
/**
* Remove an attribute from the list.
*
* @param index The index of the attribute (zero-based).
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
public void removeAttribute (int index)
{
if (index >= 0 && index < length) {
if (index < length - 1) {
System.arraycopy(data, (index+1)*5, data, index*5,
(length-index-1)*5);
}
length--;
} else {
badIndex(index);
}
}
/**
* Set the Namespace URI of a specific attribute.
*
* @param index The index of the attribute (zero-based).
* @param uri The attribute's Namespace URI, or the empty
* string for none.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
public void setURI (int index, String uri)
{
if (index >= 0 && index < length) {
data[index*5] = uri;
} else {
badIndex(index);
}
}
/**
* Set the local name of a specific attribute.
*
* @param index The index of the attribute (zero-based).
* @param localName The attribute's local name, or the empty
* string for none.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
public void setLocalName (int index, String localName)
{
if (index >= 0 && index < length) {
data[index*5+1] = localName;
} else {
badIndex(index);
}
}
/**
* Set the qualified name of a specific attribute.
*
* @param index The index of the attribute (zero-based).
* @param qName The attribute's qualified name, or the empty
* string for none.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
public void setQName (int index, String qName)
{
if (index >= 0 && index < length) {
data[index*5+2] = qName;
} else {
badIndex(index);
}
}
/**
* Set the type of a specific attribute.
*
* @param index The index of the attribute (zero-based).
* @param type The attribute's type.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
public void setType (int index, String type)
{
if (index >= 0 && index < length) {
data[index*5+3] = type;
} else {
badIndex(index);
}
}
/**
* Set the value of a specific attribute.
*
* @param index The index of the attribute (zero-based).
* @param value The attribute's value.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
public void setValue (int index, String value)
{
if (index >= 0 && index < length) {
data[index*5+4] = value;
} else {
badIndex(index);
}
}
////////////////////////////////////////////////////////////////////
// Internal methods.
////////////////////////////////////////////////////////////////////
/**
* Ensure the internal array's capacity.
*
* @param n The minimum number of attributes that the array must
* be able to hold.
*/
private void ensureCapacity (int n)
{
if (n > 0 && (data == null || data.length==0)) {
data = new String[25];
}
int max = data.length;
if (max >= n * 5) {
return;
}
while (max < n * 5) {
max *= 2;
}
String newData[] = new String[max];
System.arraycopy(data, 0, newData, 0, length*5);
data = newData;
}
/**
* Report a bad array index in a manipulator.
*
* @param index The index to report.
* @exception java.lang.ArrayIndexOutOfBoundsException Always.
*/
private void badIndex (int index)
throws ArrayIndexOutOfBoundsException
{
String msg =
"Attempt to modify attribute at illegal index: " + index;
throw new ArrayIndexOutOfBoundsException(msg);
}
////////////////////////////////////////////////////////////////////
// Internal state.
////////////////////////////////////////////////////////////////////
int length;
String data [];
}
// end of AttributesImpl.java

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
*
*
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public interface NGCCEventReceiver {
void enterElement(String uri, String localName, String qname,Attributes atts) throws SAXException;
void leaveElement(String uri, String localName, String qname) throws SAXException;
void text(String value) throws SAXException;
void enterAttribute(String uri, String localName, String qname) throws SAXException;
void leaveAttribute(String uri, String localName, String qname) throws SAXException;
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
*
*
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public interface NGCCEventSource {
/**
* Replaces an old handler with a new handler, and returns
* ID of the EventReceiver thread.
*/
int replace( NGCCEventReceiver _old, NGCCEventReceiver _new );
/** Sends an enter element event to the specified EventReceiver thread. */
void sendEnterElement( int receiverThreadId, String uri, String local, String qname, Attributes atts ) throws SAXException;
void sendLeaveElement( int receiverThreadId, String uri, String local, String qname ) throws SAXException;
void sendEnterAttribute( int receiverThreadId, String uri, String local, String qname ) throws SAXException;
void sendLeaveAttribute( int receiverThreadId, String uri, String local, String qname ) throws SAXException;
void sendText( int receiverThreadId, String value ) throws SAXException;
}

View File

@@ -0,0 +1,191 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
*
*
* @version $Id: NGCCHandler.java,v 1.9 2002/09/29 02:55:48 okajima Exp $
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public abstract class NGCCHandler implements NGCCEventReceiver {
protected NGCCHandler( NGCCEventSource source, NGCCHandler parent, int parentCookie ) {
_parent = parent;
_source = source;
_cookie = parentCookie;
}
/**
* Parent NGCCHandler, if any.
* If this is the root handler, this field will be null.
*/
protected final NGCCHandler _parent;
/**
* Event source.
*/
protected final NGCCEventSource _source;
/**
* This method will be implemented by the generated code
* and returns a reference to the current runtime.
*/
protected abstract NGCCRuntime getRuntime();
/**
* Cookie assigned by the parent.
*
* This value will be passed to the onChildCompleted handler
* of the parent.
*/
protected final int _cookie;
// used to copy parameters to (enter|leave)(Element|Attribute) events.
//protected String localName,uri,qname;
/**
* Notifies the completion of a child object.
*
* @param result
* The parsing result of the child state.
* @param cookie
* The cookie value passed to the child object
* when it is created.
* @param needAttCheck
* This flag is true when the callee needs to call the
* processAttribute method to check attribute transitions.
* This flag is set to false when this method is triggered by
* attribute transition.
*/
protected abstract void onChildCompleted( Object result, int cookie, boolean needAttCheck ) throws SAXException;
//
//
// spawns a new child object from event handlers.
//
//
public void spawnChildFromEnterElement( NGCCEventReceiver child,
String uri, String localname, String qname, Attributes atts) throws SAXException {
int id = _source.replace(this,child);
_source.sendEnterElement(id,uri,localname,qname,atts);
}
public void spawnChildFromEnterAttribute( NGCCEventReceiver child,
String uri, String localname, String qname) throws SAXException {
int id = _source.replace(this,child);
_source.sendEnterAttribute(id,uri,localname,qname);
}
public void spawnChildFromLeaveElement( NGCCEventReceiver child,
String uri, String localname, String qname) throws SAXException {
int id = _source.replace(this,child);
_source.sendLeaveElement(id,uri,localname,qname);
}
public void spawnChildFromLeaveAttribute( NGCCEventReceiver child,
String uri, String localname, String qname) throws SAXException {
int id = _source.replace(this,child);
_source.sendLeaveAttribute(id,uri,localname,qname);
}
public void spawnChildFromText( NGCCEventReceiver child,
String value) throws SAXException {
int id = _source.replace(this,child);
_source.sendText(id,value);
}
//
//
// reverts to the parent object from the child handler
//
//
public void revertToParentFromEnterElement( Object result, int cookie,
String uri,String local,String qname, Attributes atts ) throws SAXException {
int id = _source.replace(this,_parent);
_parent.onChildCompleted(result,cookie,true);
_source.sendEnterElement(id,uri,local,qname,atts);
}
public void revertToParentFromLeaveElement( Object result, int cookie,
String uri,String local,String qname ) throws SAXException {
if(uri==NGCCRuntime.IMPOSSIBLE && uri==local && uri==qname && _parent==null )
// all the handlers are properly finalized.
// quit now, because we don't have any more NGCCHandler.
// see the endDocument handler for detail
return;
int id = _source.replace(this,_parent);
_parent.onChildCompleted(result,cookie,true);
_source.sendLeaveElement(id,uri,local,qname);
}
public void revertToParentFromEnterAttribute( Object result, int cookie,
String uri,String local,String qname ) throws SAXException {
int id = _source.replace(this,_parent);
_parent.onChildCompleted(result,cookie,true);
_source.sendEnterAttribute(id,uri,local,qname);
}
public void revertToParentFromLeaveAttribute( Object result, int cookie,
String uri,String local,String qname ) throws SAXException {
int id = _source.replace(this,_parent);
_parent.onChildCompleted(result,cookie,true);
_source.sendLeaveAttribute(id,uri,local,qname);
}
public void revertToParentFromText( Object result, int cookie,
String text ) throws SAXException {
int id = _source.replace(this,_parent);
_parent.onChildCompleted(result,cookie,true);
_source.sendText(id,text);
}
//
//
// error handler
//
//
public void unexpectedEnterElement(String qname) throws SAXException {
getRuntime().unexpectedX('<'+qname+'>');
}
public void unexpectedLeaveElement(String qname) throws SAXException {
getRuntime().unexpectedX("</"+qname+'>');
}
public void unexpectedEnterAttribute(String qname) throws SAXException {
getRuntime().unexpectedX('@'+qname);
}
public void unexpectedLeaveAttribute(String qname) throws SAXException {
getRuntime().unexpectedX("/@"+qname);
}
}

View File

@@ -0,0 +1,350 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* Dispatches incoming events into sub handlers appropriately
* so that the interleaving semantics will be correctly realized.
*
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public abstract class NGCCInterleaveFilter implements NGCCEventSource, NGCCEventReceiver {
protected NGCCInterleaveFilter( NGCCHandler parent, int cookie ) {
this._parent = parent;
this._cookie = cookie;
}
protected void setHandlers( NGCCEventReceiver[] receivers ) {
this._receivers = receivers;
}
/** event receiverse. */
protected NGCCEventReceiver[] _receivers;
public int replace(NGCCEventReceiver oldHandler, NGCCEventReceiver newHandler) {
for( int i=0; i<_receivers.length; i++ )
if( _receivers[i]==oldHandler ) {
_receivers[i]=newHandler;
return i;
}
throw new InternalError(); // a bug in RelaxNGCC.
}
/** Parent handler. */
private final NGCCHandler _parent;
/** Cookie given by the parent. */
private final int _cookie;
//
//
// event handler
//
//
/**
* Receiver that is being locked and therefore receives all the events.
* <pre><xmp>
* <interleave>
* <element name="foo"/>
* <element name="bar">
* <element name="foo"/>
* </element>
* </interlaeve>
* </xmp></pre>
* When processing inside the bar element, this receiver is
* "locked" so that it can correctly receive its child foo element.
*/
private int lockedReceiver;
/**
* Nest level. Lock will be release when the lockCount becomes 0.
*/
private int lockCount=0;
public void enterElement(
String uri, String localName, String qname,Attributes atts) throws SAXException {
if(isJoining) return; // ignore any token if we are joining. See joinByXXXX.
if(lockCount++==0) {
lockedReceiver = findReceiverOfElement(uri,localName);
if(lockedReceiver==-1) {
// we can't process this token. join.
joinByEnterElement(null,uri,localName,qname,atts);
return;
}
}
_receivers[lockedReceiver].enterElement(uri,localName,qname,atts);
}
public void leaveElement(String uri, String localName, String qname) throws SAXException {
if(isJoining) return; // ignore any token if we are joining. See joinByXXXX.
if( lockCount-- == 0 )
joinByLeaveElement(null,uri,localName,qname);
else
_receivers[lockedReceiver].leaveElement(uri,localName,qname);
}
public void enterAttribute(String uri, String localName, String qname) throws SAXException {
if(isJoining) return; // ignore any token if we are joining. See joinByXXXX.
if(lockCount++==0) {
lockedReceiver = findReceiverOfAttribute(uri,localName);
if(lockedReceiver==-1) {
// we can't process this token. join.
joinByEnterAttribute(null,uri,localName,qname);
return;
}
}
_receivers[lockedReceiver].enterAttribute(uri,localName,qname);
}
public void leaveAttribute(String uri, String localName, String qname) throws SAXException {
if(isJoining) return; // ignore any token if we are joining. See joinByXXXX.
if( lockCount-- == 0 )
joinByLeaveAttribute(null,uri,localName,qname);
else
_receivers[lockedReceiver].leaveAttribute(uri,localName,qname);
}
public void text(String value) throws SAXException {
if(isJoining) return; // ignore any token if we are joining. See joinByXXXX.
if(lockCount!=0)
_receivers[lockedReceiver].text(value);
else {
int receiver = findReceiverOfText();
if(receiver!=-1) _receivers[receiver].text(value);
else joinByText(null,value);
}
}
/**
* Implemented by the generated code to determine the handler
* that can receive the given element.
*
* @return
* Thread ID of the receiver that can handle this event,
* or -1 if none.
*/
protected abstract int findReceiverOfElement( String uri, String local );
/**
* Returns the handler that can receive the given attribute, or null.
*/
protected abstract int findReceiverOfAttribute( String uri, String local );
/**
* Returns the handler that can receive text events, or null.
*/
protected abstract int findReceiverOfText();
//
//
// join method
//
//
/**
* Set to true when this handler is in the process of
* joining all branches.
*/
private boolean isJoining = false;
/**
* Joins all the child receivers.
*
* <p>
* This method is called by a child receiver when it sees
* something that it cannot handle, or by this object itself
* when it sees an event that it can't process.
*
* <p>
* This method forces children to move to its final state,
* then revert to the parent.
*
* @param source
* If this method is called by one of the child receivers,
* the receiver object. If this method is called by itself,
* null.
*/
public void joinByEnterElement( NGCCEventReceiver source,
String uri, String local, String qname, Attributes atts ) throws SAXException {
if(isJoining) return; // we are already in the process of joining. ignore.
isJoining = true;
// send special token to the rest of the branches.
// these branches don't understand this token, so they will
// try to move to a final state and send the token back to us,
// which this object will ignore (because isJoining==true)
// Otherwise branches will find an error.
for( int i=0; i<_receivers.length; i++ )
if( _receivers[i]!=source )
_receivers[i].enterElement(uri,local,qname,atts);
// revert to the parent
_parent._source.replace(this,_parent);
_parent.onChildCompleted(null,_cookie,true);
// send this event to the parent
_parent.enterElement(uri,local,qname,atts);
}
public void joinByLeaveElement( NGCCEventReceiver source,
String uri, String local, String qname ) throws SAXException {
if(isJoining) return; // we are already in the process of joining. ignore.
isJoining = true;
// send special token to the rest of the branches.
// these branches don't understand this token, so they will
// try to move to a final state and send the token back to us,
// which this object will ignore (because isJoining==true)
// Otherwise branches will find an error.
for( int i=0; i<_receivers.length; i++ )
if( _receivers[i]!=source )
_receivers[i].leaveElement(uri,local,qname);
// revert to the parent
_parent._source.replace(this,_parent);
_parent.onChildCompleted(null,_cookie,true);
// send this event to the parent
_parent.leaveElement(uri,local,qname);
}
public void joinByEnterAttribute( NGCCEventReceiver source,
String uri, String local, String qname ) throws SAXException {
if(isJoining) return; // we are already in the process of joining. ignore.
isJoining = true;
// send special token to the rest of the branches.
// these branches don't understand this token, so they will
// try to move to a final state and send the token back to us,
// which this object will ignore (because isJoining==true)
// Otherwise branches will find an error.
for( int i=0; i<_receivers.length; i++ )
if( _receivers[i]!=source )
_receivers[i].enterAttribute(uri,local,qname);
// revert to the parent
_parent._source.replace(this,_parent);
_parent.onChildCompleted(null,_cookie,true);
// send this event to the parent
_parent.enterAttribute(uri,local,qname);
}
public void joinByLeaveAttribute( NGCCEventReceiver source,
String uri, String local, String qname ) throws SAXException {
if(isJoining) return; // we are already in the process of joining. ignore.
isJoining = true;
// send special token to the rest of the branches.
// these branches don't understand this token, so they will
// try to move to a final state and send the token back to us,
// which this object will ignore (because isJoining==true)
// Otherwise branches will find an error.
for( int i=0; i<_receivers.length; i++ )
if( _receivers[i]!=source )
_receivers[i].leaveAttribute(uri,local,qname);
// revert to the parent
_parent._source.replace(this,_parent);
_parent.onChildCompleted(null,_cookie,true);
// send this event to the parent
_parent.leaveAttribute(uri,local,qname);
}
public void joinByText( NGCCEventReceiver source,
String value ) throws SAXException {
if(isJoining) return; // we are already in the process of joining. ignore.
isJoining = true;
// send special token to the rest of the branches.
// these branches don't understand this token, so they will
// try to move to a final state and send the token back to us,
// which this object will ignore (because isJoining==true)
// Otherwise branches will find an error.
for( int i=0; i<_receivers.length; i++ )
if( _receivers[i]!=source )
_receivers[i].text(value);
// revert to the parent
_parent._source.replace(this,_parent);
_parent.onChildCompleted(null,_cookie,true);
// send this event to the parent
_parent.text(value);
}
//
//
// event dispatching methods
//
//
public void sendEnterAttribute( int threadId,
String uri, String local, String qname) throws SAXException {
_receivers[threadId].enterAttribute(uri,local,qname);
}
public void sendEnterElement( int threadId,
String uri, String local, String qname, Attributes atts) throws SAXException {
_receivers[threadId].enterElement(uri,local,qname,atts);
}
public void sendLeaveAttribute( int threadId,
String uri, String local, String qname) throws SAXException {
_receivers[threadId].leaveAttribute(uri,local,qname);
}
public void sendLeaveElement( int threadId,
String uri, String local, String qname) throws SAXException {
_receivers[threadId].leaveElement(uri,local,qname);
}
public void sendText(int threadId, String value) throws SAXException {
_receivers[threadId].text(value);
}
}

View File

@@ -0,0 +1,555 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.parser.state;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Stack;
import java.util.StringTokenizer;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
* Runtime Engine for RELAXNGCC execution.
*
* This class has the following functionalities:
*
* <ol>
* <li>Managing a stack of NGCCHandler objects and
* switching between them appropriately.
*
* <li>Keep track of all Attributes.
*
* <li>manage mapping between namespace URIs and prefixes.
*
* <li>TODO: provide support for interleaving.
*
* @version $Id: NGCCRuntime.java,v 1.15 2002/09/29 02:55:48 okajima Exp $
* @author Kohsuke Kawaguchi (kk@kohsuke.org)
*/
public class NGCCRuntime implements ContentHandler, NGCCEventSource {
public NGCCRuntime() {
reset();
}
/**
* Sets the root handler, which will be used to parse the
* root element.
* <p>
* This method can be called right after the object is created
* or the reset method is called. You can't replace the root
* handler while parsing is in progress.
* <p>
* Usually a generated class that corresponds to the &lt;start>
* pattern will be used as the root handler, but any NGCCHandler
* can be a root handler.
*
* @exception IllegalStateException
* If this method is called but it doesn't satisfy the
* pre-condition stated above.
*/
public void setRootHandler( NGCCHandler rootHandler ) {
if(currentHandler!=null)
throw new IllegalStateException();
currentHandler = rootHandler;
}
/**
* Cleans up all the data structure so that the object can be reused later.
* Normally, applications do not need to call this method directly,
*
* as the runtime resets itself after the endDocument method.
*/
public void reset() {
attStack.clear();
currentAtts = null;
currentHandler = null;
indent=0;
locator = null;
namespaces.clear();
needIndent = true;
redirect = null;
redirectionDepth = 0;
text = new StringBuffer();
// add a dummy attributes at the bottom as a "centinel."
attStack.push(new AttributesImpl());
}
// current content handler can be acccessed via set/getContentHandler.
private Locator locator;
public void setDocumentLocator( Locator _loc ) { this.locator=_loc; }
/**
* Gets the source location of the current event.
*
* <p>
* One can call this method from RelaxNGCC handlers to access
* the line number information. Note that to
*/
public Locator getLocator() { return locator; }
/** stack of {@link Attributes}. */
private final Stack attStack = new Stack();
/** current attributes set. always equal to attStack.peek() */
private AttributesImpl currentAtts;
/**
* Attributes that belong to the current element.
* <p>
* It's generally not recommended for applications to use
* this method. RelaxNGCC internally removes processed attributes,
* so this doesn't correctly reflect all the attributes an element
* carries.
*/
public Attributes getCurrentAttributes() {
return currentAtts;
}
/** accumulated text. */
private StringBuffer text = new StringBuffer();
/** The current NGCCHandler. Always equals to handlerStack.peek() */
private NGCCEventReceiver currentHandler;
public int replace( NGCCEventReceiver o, NGCCEventReceiver n ) {
if(o!=currentHandler)
throw new IllegalStateException(); // bug of RelaxNGCC
currentHandler = n;
return 0; // we only have one thread.
}
/**
* Processes buffered text.
*
* This method will be called by the start/endElement event to process
* buffered text as a text event.
*
* <p>
* Whitespace handling is a tricky business. Consider the following
* schema fragment:
*
* <xmp>
* <element name="foo">
* <choice>
* <element name="bar"><empty/></element>
* <text/>
* </choice>
* </element>
* </xmp>
*
* Assume we hit the following instance:
* <xmp>
* <foo> <bar/></foo>
* </xmp>
*
* Then this first space needs to be ignored (for otherwise, we will
* end up treating this space as the match to &lt;text/> and won't
* be able to process &lt;bar>.)
*
* Now assume the following instance:
* <xmp>
* <foo/>
* </xmp>
*
* This time, we need to treat this empty string as a text, for
* otherwise we won't be able to accept this instance.
*
* <p>
* This is very difficult to solve in general, but one seemingly
* easy solution is to use the type of next event. If a text is
* followed by a start tag, it follows from the constraint on
* RELAX NG that that text must be either whitespaces or a match
* to &lt;text/>.
*
* <p>
* On the contrary, if a text is followed by a end tag, then it
* cannot be whitespace unless the content model can accept empty,
* in which case sending a text event will be harmlessly ignored
* by the NGCCHandler.
*
* <p>
* Thus this method take one parameter, which controls the
* behavior of this method.
*
* <p>
* TODO: according to the constraint of RELAX NG, if characters
* follow an end tag, then they must be either whitespaces or
* must match to &lt;text/>.
*
* @param possiblyWhitespace
* True if the buffered character can be ignorabale. False if
* it needs to be consumed.
*/
private void processPendingText(boolean ignorable) throws SAXException {
if(ignorable && text.toString().trim().length()==0)
; // ignore. See the above javadoc comment for the description
else
currentHandler.text(text.toString()); // otherwise consume this token
// truncate StringBuffer, but avoid excessive allocation.
if(text.length()>1024) text = new StringBuffer();
else text.setLength(0);
}
public void processList( String str ) throws SAXException {
StringTokenizer t = new StringTokenizer(str, " \t\r\n");
while(t.hasMoreTokens())
currentHandler.text(t.nextToken());
}
public void startElement(String uri, String localname, String qname, Attributes atts)
throws SAXException {
if(redirect!=null) {
redirect.startElement(uri,localname,qname,atts);
redirectionDepth++;
} else {
processPendingText(true);
// System.out.println("startElement:"+localname+"->"+_attrStack.size());
currentHandler.enterElement(uri, localname, qname, atts);
}
}
/**
* Called by the generated handler code when an enter element
* event is consumed.
*
* <p>
* Pushes a new attribute set.
*
* <p>
* Note that attributes are NOT pushed at the startElement method,
* because the processing of the enterElement event can trigger
* other attribute events and etc.
* <p>
* This method will be called from one of handlers when it truely
* consumes the enterElement event.
*/
public void onEnterElementConsumed(
String uri, String localName, String qname,Attributes atts) throws SAXException {
attStack.push(currentAtts=new AttributesImpl(atts));
nsEffectiveStack.push( new Integer(nsEffectivePtr) );
nsEffectivePtr = namespaces.size();
}
public void onLeaveElementConsumed(String uri, String localName, String qname) throws SAXException {
attStack.pop();
if(attStack.isEmpty())
currentAtts = null;
else
currentAtts = (AttributesImpl)attStack.peek();
nsEffectivePtr = ((Integer)nsEffectiveStack.pop()).intValue();
}
public void endElement(String uri, String localname, String qname)
throws SAXException {
if(redirect!=null) {
redirect.endElement(uri,localname,qname);
redirectionDepth--;
if(redirectionDepth!=0)
return;
// finished redirection.
for( int i=0; i<namespaces.size(); i+=2 )
redirect.endPrefixMapping((String)namespaces.get(i));
redirect.endDocument();
redirect = null;
// then process this element normally
}
processPendingText(false);
currentHandler.leaveElement(uri, localname, qname);
// System.out.println("endElement:"+localname);
}
public void characters(char[] ch, int start, int length) throws SAXException {
if(redirect!=null)
redirect.characters(ch,start,length);
else
text.append(ch,start,length);
}
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
if(redirect!=null)
redirect.ignorableWhitespace(ch,start,length);
else
text.append(ch,start,length);
}
public int getAttributeIndex(String uri, String localname) {
return currentAtts.getIndex(uri, localname);
}
public void consumeAttribute(int index) throws SAXException {
final String uri = currentAtts.getURI(index);
final String local = currentAtts.getLocalName(index);
final String qname = currentAtts.getQName(index);
final String value = currentAtts.getValue(index);
currentAtts.removeAttribute(index);
currentHandler.enterAttribute(uri,local,qname);
currentHandler.text(value);
currentHandler.leaveAttribute(uri,local,qname);
}
public void startPrefixMapping( String prefix, String uri ) throws SAXException {
if(redirect!=null)
redirect.startPrefixMapping(prefix,uri);
else {
namespaces.add(prefix);
namespaces.add(uri);
}
}
public void endPrefixMapping( String prefix ) throws SAXException {
if(redirect!=null)
redirect.endPrefixMapping(prefix);
else {
namespaces.remove(namespaces.size()-1);
namespaces.remove(namespaces.size()-1);
}
}
public void skippedEntity( String name ) throws SAXException {
if(redirect!=null)
redirect.skippedEntity(name);
}
public void processingInstruction( String target, String data ) throws SAXException {
if(redirect!=null)
redirect.processingInstruction(target,data);
}
/** Impossible token. This value can never be a valid XML name. */
static final String IMPOSSIBLE = "\u0000";
public void endDocument() throws SAXException {
// consume the special "end document" token so that all the handlers
// currently at the stack will revert to their respective parents.
//
// this is necessary to handle a grammar like
// <start><ref name="X"/></start>
// <define name="X">
// <element name="root"><empty/></element>
// </define>
//
// With this grammar, when the endElement event is consumed, two handlers
// are on the stack (because a child object won't revert to its parent
// unless it sees a next event.)
// pass around an "impossible" token.
currentHandler.leaveElement(IMPOSSIBLE,IMPOSSIBLE,IMPOSSIBLE);
reset();
}
public void startDocument() {}
//
//
// event dispatching methods
//
//
public void sendEnterAttribute( int threadId,
String uri, String local, String qname) throws SAXException {
currentHandler.enterAttribute(uri,local,qname);
}
public void sendEnterElement( int threadId,
String uri, String local, String qname, Attributes atts) throws SAXException {
currentHandler.enterElement(uri,local,qname,atts);
}
public void sendLeaveAttribute( int threadId,
String uri, String local, String qname) throws SAXException {
currentHandler.leaveAttribute(uri,local,qname);
}
public void sendLeaveElement( int threadId,
String uri, String local, String qname) throws SAXException {
currentHandler.leaveElement(uri,local,qname);
}
public void sendText(int threadId, String value) throws SAXException {
currentHandler.text(value);
}
//
//
// redirection of SAX2 events.
//
//
/** When redirecting a sub-tree, this value will be non-null. */
private ContentHandler redirect = null;
/**
* Counts the depth of the elements when we are re-directing
* a sub-tree to another ContentHandler.
*/
private int redirectionDepth = 0;
/**
* This method can be called only from the enterElement handler.
* The sub-tree rooted at the new element will be redirected
* to the specified ContentHandler.
*
* <p>
* Currently active NGCCHandler will only receive the leaveElement
* event of the newly started element.
*
* @param uri,local,qname
* Parameters passed to the enter element event. Used to
* simulate the startElement event for the new ContentHandler.
*/
public void redirectSubtree( ContentHandler child,
String uri, String local, String qname ) throws SAXException {
redirect = child;
redirect.setDocumentLocator(locator);
redirect.startDocument();
// TODO: when a prefix is re-bound to something else,
// the following code is potentially dangerous. It should be
// modified to report active bindings only.
for( int i=0; i<namespaces.size(); i+=2 )
redirect.startPrefixMapping(
(String)namespaces.get(i),
(String)namespaces.get(i+1)
);
redirect.startElement(uri,local,qname,currentAtts);
redirectionDepth=1;
}
//
//
// validation context implementation
//
//
/** in-scope namespace mapping.
* namespaces[2n ] := prefix
* namespaces[2n+1] := namespace URI */
private final ArrayList namespaces = new ArrayList();
/**
* Index on the namespaces array, which points to
* the top of the effective bindings. Because of the
* timing difference between the startPrefixMapping method
* and the execution of the corresponding actions,
* this value can be different from <code>namespaces.size()</code>.
* <p>
* For example, consider the following schema:
* <pre><xmp>
* <oneOrMore>
* <element name="foo"><empty/></element>
* </oneOrMore>
* code fragment X
* <element name="bob"/>
* </xmp></pre>
* Code fragment X is executed after we see a startElement event,
* but at this time the namespaces variable already include new
* namespace bindings declared on "bob".
*/
private int nsEffectivePtr=0;
/**
* Stack to preserve old nsEffectivePtr values.
*/
private final Stack nsEffectiveStack = new Stack();
public String resolveNamespacePrefix( String prefix ) {
for( int i = nsEffectivePtr-2; i>=0; i-=2 )
if( namespaces.get(i).equals(prefix) )
return (String)namespaces.get(i+1);
// no binding was found.
if(prefix.equals("")) return ""; // return the default no-namespace
if(prefix.equals("xml")) // pre-defined xml prefix
return "http://www.w3.org/XML/1998/namespace";
else return null; // prefix undefined
}
// error reporting
protected void unexpectedX(String token) throws SAXException {
throw new SAXParseException(MessageFormat.format(
"Unexpected {0} appears at line {1} column {2}",
new Object[]{
token,
new Integer(getLocator().getLineNumber()),
new Integer(getLocator().getColumnNumber()) }),
getLocator());
}
//
//
// trace functions
//
//
private int indent=0;
private boolean needIndent=true;
private void printIndent() {
for( int i=0; i<indent; i++ )
System.out.print(" ");
}
public void trace( String s ) {
if(needIndent) {
needIndent=false;
printIndent();
}
System.out.print(s);
}
public void traceln( String s ) {
trace(s);
trace("\n");
needIndent=true;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,390 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class SimpleType_List extends NGCCHandler {
private Locator locator;
private AnnotationImpl annotation;
private String name;
private UName itemTypeName;
private Set finalSet;
private ForeignAttributesImpl fa;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public SimpleType_List(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
super(source, parent, cookie);
$runtime = runtime;
this.annotation = _annotation;
this.locator = _locator;
this.fa = _fa;
this.name = _name;
this.finalSet = _finalSet;
$_ngcc_current_state = 10;
}
public SimpleType_List(NGCCRuntimeEx runtime, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
this(null, runtime, runtime, -1, _annotation, _locator, _fa, _name, _finalSet);
}
private void action0()throws SAXException {
result = new ListSimpleTypeImpl(
$runtime.document, annotation, locator, fa,
name, name==null, finalSet, itemType );
}
private void action1()throws SAXException {
itemType = new DelayedRef.SimpleType(
$runtime, lloc, $runtime.currentSchema, itemTypeName);
}
private void action2()throws SAXException {
lloc=$runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 9:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || ((($ai = $runtime.getAttributeIndex("","itemType"))>=0 && (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 266, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 7:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 264, annotation,AnnotationContext.SIMPLETYPE_DECL);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 10:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("list"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action2();
$_ngcc_current_state = 9;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 2:
{
if(($ai = $runtime.getAttributeIndex("","itemType"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
NGCCHandler h = new simpleType(this, super._source, $runtime, 258);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
}
break;
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 9:
{
if((($ai = $runtime.getAttributeIndex("","itemType"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("list")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 266, fa);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 7:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
if(($ai = $runtime.getAttributeIndex("","itemType"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("list"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
action0();
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 9:
{
if(($__uri.equals("") && $__local.equals("itemType"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 266, fa);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 7:
{
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
if(($__uri.equals("") && $__local.equals("itemType"))) {
$_ngcc_current_state = 5;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 7:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
if(($__uri.equals("") && $__local.equals("itemType"))) {
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 9:
{
if(($ai = $runtime.getAttributeIndex("","itemType"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 266, fa);
spawnChildFromText(h, $value);
}
}
break;
case 7:
{
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
break;
case 2:
{
if(($ai = $runtime.getAttributeIndex("","itemType"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
case 5:
{
NGCCHandler h = new qname(this, super._source, $runtime, 260);
spawnChildFromText(h, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 266:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 7;
}
break;
case 264:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 2;
}
break;
case 258:
{
itemType = ((SimpleTypeImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
case 260:
{
itemTypeName = ((UName)$__result__);
action1();
$_ngcc_current_state = 4;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
/** computed simple type object */
private ListSimpleTypeImpl result;
// reference to the base type
private Ref.SimpleType itemType;
// locator of <list>
private Locator lloc;
}

View File

@@ -0,0 +1,491 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class SimpleType_Restriction extends NGCCHandler {
private Locator locator;
private AnnotationImpl annotation;
private String name;
private UName baseTypeName;
private Set finalSet;
private ForeignAttributesImpl fa;
private XSFacet facet;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public SimpleType_Restriction(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
super(source, parent, cookie);
$runtime = runtime;
this.annotation = _annotation;
this.locator = _locator;
this.fa = _fa;
this.name = _name;
this.finalSet = _finalSet;
$_ngcc_current_state = 13;
}
public SimpleType_Restriction(NGCCRuntimeEx runtime, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
this(null, runtime, runtime, -1, _annotation, _locator, _fa, _name, _finalSet);
}
private void action0()throws SAXException {
result.addFacet(facet);
}
private void action1()throws SAXException {
result = new RestrictionSimpleTypeImpl(
$runtime.document, annotation, locator, fa, name, name==null, finalSet, baseType );
}
private void action2()throws SAXException {
baseType = new DelayedRef.SimpleType(
$runtime, rloc, $runtime.currentSchema, baseTypeName );
}
private void action3()throws SAXException {
rloc=$runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 12:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || ((($ai = $runtime.getAttributeIndex("","base"))>=0 && ((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType")) || (((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 10:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 164, annotation,AnnotationContext.SIMPLETYPE_DECL);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 5;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 4:
{
action1();
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","base"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
NGCCHandler h = new simpleType(this, super._source, $runtime, 158);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
}
break;
case 1:
{
if((((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) {
NGCCHandler h = new facet(this, super._source, $runtime, 153);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 2:
{
if((((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) {
NGCCHandler h = new facet(this, super._source, $runtime, 154);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 13:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action3();
$_ngcc_current_state = 12;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 12:
{
if((($ai = $runtime.getAttributeIndex("","base"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 10:
{
$_ngcc_current_state = 5;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
action1();
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","base"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 12:
{
if(($__uri.equals("") && $__local.equals("base"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 10:
{
$_ngcc_current_state = 5;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
action1();
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
if(($__uri.equals("") && $__local.equals("base"))) {
$_ngcc_current_state = 8;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 7:
{
if(($__uri.equals("") && $__local.equals("base"))) {
$_ngcc_current_state = 4;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 10:
{
$_ngcc_current_state = 5;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
action1();
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 8:
{
NGCCHandler h = new qname(this, super._source, $runtime, 160);
spawnChildFromText(h, $value);
}
break;
case 12:
{
if(($ai = $runtime.getAttributeIndex("","base"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
spawnChildFromText(h, $value);
}
}
break;
case 10:
{
$_ngcc_current_state = 5;
$runtime.sendText(super._cookie, $value);
}
break;
case 4:
{
action1();
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
break;
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","base"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 160:
{
baseTypeName = ((UName)$__result__);
action2();
$_ngcc_current_state = 7;
}
break;
case 164:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 5;
}
break;
case 154:
{
facet = ((XSFacet)$__result__);
action0();
$_ngcc_current_state = 1;
}
break;
case 166:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 10;
}
break;
case 158:
{
baseType = ((SimpleTypeImpl)$__result__);
$_ngcc_current_state = 4;
}
break;
case 153:
{
facet = ((XSFacet)$__result__);
action0();
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
/** computed simple type object */
private RestrictionSimpleTypeImpl result;
// reference to the base type
private Ref.SimpleType baseType;
// location of restriction
private Locator rloc;
}

View File

@@ -0,0 +1,465 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Vector;
class SimpleType_Union extends NGCCHandler {
private Locator locator;
private AnnotationImpl annotation;
private String __text;
private UName memberTypeName;
private String name;
private Set finalSet;
private ForeignAttributesImpl fa;
private SimpleTypeImpl anonymousMemberType;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public SimpleType_Union(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
super(source, parent, cookie);
$runtime = runtime;
this.annotation = _annotation;
this.locator = _locator;
this.fa = _fa;
this.name = _name;
this.finalSet = _finalSet;
$_ngcc_current_state = 12;
}
public SimpleType_Union(NGCCRuntimeEx runtime, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
this(null, runtime, runtime, -1, _annotation, _locator, _fa, _name, _finalSet);
}
private void action0()throws SAXException {
result = new UnionSimpleTypeImpl(
$runtime.document, annotation, locator, fa, name, name==null, finalSet,
(Ref.SimpleType[])members.toArray(new Ref.SimpleType[members.size()]) );
}
private void action1()throws SAXException {
members.add(anonymousMemberType);
}
private void action2()throws SAXException {
members.add( new DelayedRef.SimpleType(
$runtime, uloc, $runtime.currentSchema, memberTypeName));
}
private void action3()throws SAXException {
$runtime.processList(__text);}
private void action4()throws SAXException {
uloc=$runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 183, annotation,AnnotationContext.SIMPLETYPE_DECL);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
NGCCHandler h = new simpleType(this, super._source, $runtime, 179);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 7:
{
if(($ai = $runtime.getAttributeIndex("","memberTypes"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 6;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 12:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("union"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action4();
$_ngcc_current_state = 7;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
NGCCHandler h = new simpleType(this, super._source, $runtime, 180);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 6:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 185, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("union"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
action0();
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 7:
{
if(($ai = $runtime.getAttributeIndex("","memberTypes"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 6;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("union"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 185, fa);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
if(($__uri.equals("") && $__local.equals("memberTypes"))) {
$_ngcc_current_state = 10;
}
else {
$_ngcc_current_state = 6;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
$_ngcc_current_state = 6;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 8:
{
if(($__uri.equals("") && $__local.equals("memberTypes"))) {
$_ngcc_current_state = 6;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
break;
case 9:
{
NGCCHandler h = new qname(this, super._source, $runtime, 187);
spawnChildFromText(h, $value);
}
break;
case 10:
{
__text = $value;
$_ngcc_current_state = 9;
action3();
}
break;
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
case 7:
{
if(($ai = $runtime.getAttributeIndex("","memberTypes"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 6;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 8:
{
NGCCHandler h = new qname(this, super._source, $runtime, 188);
spawnChildFromText(h, $value);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 183:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 2;
}
break;
case 187:
{
memberTypeName = ((UName)$__result__);
action2();
$_ngcc_current_state = 8;
}
break;
case 179:
{
anonymousMemberType = ((SimpleTypeImpl)$__result__);
action1();
$_ngcc_current_state = 1;
}
break;
case 188:
{
memberTypeName = ((UName)$__result__);
action2();
$_ngcc_current_state = 8;
}
break;
case 185:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 4;
}
break;
case 180:
{
anonymousMemberType = ((SimpleTypeImpl)$__result__);
action1();
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
/** computed simple type object */
private UnionSimpleTypeImpl result;
// Vector of Ref.SimpleType
private final Vector members = new Vector();
// locator of <union>
private Locator uloc;
}

View File

@@ -0,0 +1,214 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
import com.sun.xml.internal.xsom.parser.AnnotationParser;
class annotation extends NGCCHandler {
private AnnotationContext context;
private AnnotationImpl existing;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public annotation(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, AnnotationImpl _existing, AnnotationContext _context) {
super(source, parent, cookie);
$runtime = runtime;
this.existing = _existing;
this.context = _context;
$_ngcc_current_state = 2;
}
public annotation(NGCCRuntimeEx runtime, AnnotationImpl _existing, AnnotationContext _context) {
this(null, runtime, runtime, -1, _existing, _context);
}
private void action0()throws SAXException {
locator = $runtime.copyLocator();
parser = $runtime.createAnnotationParser();
$runtime.redirectSubtree(parser.getContentHandler(
context,
$runtime.getAnnotationContextElementName(),
$runtime.getErrorHandler(),
$runtime.parser.getEntityResolver()
), $uri, $localName, $qname );
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action0();
$_ngcc_current_state = 1;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private AnnotationParser parser;
private Locator locator;
public AnnotationImpl makeResult() {
Object e = null;
if(existing!=null) e=existing.getAnnotation();
return new AnnotationImpl( parser.getResult(e),locator);
}
}

View File

@@ -0,0 +1,535 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import com.sun.xml.internal.bind.WhiteSpaceProcessor;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import com.sun.xml.internal.xsom.parser.*;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
class attributeDeclBody extends NGCCHandler {
private String name;
private ForeignAttributesImpl fa;
private AnnotationImpl annotation;
private Locator locator;
private boolean isLocal;
private String defaultValue;
private UName typeName;
private String fixedValue;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public attributeDeclBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue) {
super(source, parent, cookie);
$runtime = runtime;
this.locator = _locator;
this.isLocal = _isLocal;
this.defaultValue = _defaultValue;
this.fixedValue = _fixedValue;
$_ngcc_current_state = 13;
}
public attributeDeclBody(NGCCRuntimeEx runtime, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue) {
this(null, runtime, runtime, -1, _locator, _isLocal, _defaultValue, _fixedValue);
}
private void action0()throws SAXException {
type = new DelayedRef.SimpleType(
$runtime, locator, $runtime.currentSchema, typeName );
}
private void action1()throws SAXException {
formSpecified = true;
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 12:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 7:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 388, null,AnnotationContext.ATTRIBUTE_DECL);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 9:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || ((($ai = $runtime.getAttributeIndex("","type"))>=0 && (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","form"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 12;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 1:
{
if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
NGCCHandler h = new simpleType(this, super._source, $runtime, 379);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 12:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 7:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 9:
{
if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","form"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 12;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 1:
{
if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 0;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 12:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 11;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 7:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 9:
{
if(($__uri.equals("") && $__local.equals("type"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
}
break;
case 13:
{
if(($__uri.equals("") && $__local.equals("form"))) {
$_ngcc_current_state = 15;
}
else {
$_ngcc_current_state = 12;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 1:
{
if(($__uri.equals("") && $__local.equals("type"))) {
$_ngcc_current_state = 5;
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 14:
{
if(($__uri.equals("") && $__local.equals("form"))) {
$_ngcc_current_state = 12;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 7:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 10:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 9;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 9:
{
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
}
break;
case 13:
{
$_ngcc_current_state = 12;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
if(($__uri.equals("") && $__local.equals("type"))) {
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
case 12:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 7:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
case 9:
{
if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromText(h, $value);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
spawnChildFromText(h, $value);
}
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","form"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 12;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 15:
{
if($value.equals("unqualified")) {
NGCCHandler h = new qualification(this, super._source, $runtime, 395);
spawnChildFromText(h, $value);
}
else {
if($value.equals("qualified")) {
NGCCHandler h = new qualification(this, super._source, $runtime, 395);
spawnChildFromText(h, $value);
}
}
}
break;
case 1:
{
if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 0;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 11:
{
name = WhiteSpaceProcessor.collapse($value);
$_ngcc_current_state = 10;
}
break;
case 5:
{
NGCCHandler h = new qname(this, super._source, $runtime, 381);
spawnChildFromText(h, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 388:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
case 379:
{
type = ((SimpleTypeImpl)$__result__);
$_ngcc_current_state = 0;
}
break;
case 390:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 7;
}
break;
case 395:
{
form = ((Boolean)$__result__).booleanValue();
action1();
$_ngcc_current_state = 14;
}
break;
case 381:
{
typeName = ((UName)$__result__);
action0();
$_ngcc_current_state = 4;
}
break;
}
}
public boolean accepted() {
return((($_ngcc_current_state == 0) || (($_ngcc_current_state == 1) || ($_ngcc_current_state == 7))));
}
private boolean form;
private boolean formSpecified = false;
private AttributeDeclImpl makeResult() {
if(type==null)
// type defaults to anySimpleType
type = $runtime.parser.schemaSet.anySimpleType;
if(!formSpecified) form = $runtime.attributeFormDefault;
// global attributes are always qualified
if(!isLocal) form = true;
String tns;
if(form==true) tns = $runtime.currentSchema.getTargetNamespace();
else tns = "";
// proper handling of anonymous types
return new AttributeDeclImpl( $runtime.document, tns, name,
annotation, locator, fa, isLocal,
$runtime.createXmlString(defaultValue),
$runtime.createXmlString(fixedValue),
type );
}
private Ref.SimpleType type;
}

View File

@@ -0,0 +1,451 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import com.sun.xml.internal.bind.WhiteSpaceProcessor;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.parser.*;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
class attributeGroupDecl extends NGCCHandler {
private AnnotationImpl annotation;
private String name;
private ForeignAttributesImpl fa;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public attributeGroupDecl(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 14;
}
public attributeGroupDecl(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
result = new AttGroupDeclImpl(
$runtime.document, annotation, locator, fa, name );
}
private void action1()throws SAXException {
locator=$runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 6:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute")))))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 246, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 7:
{
if(($ai = $runtime.getAttributeIndex("","id"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 6;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 3:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 2:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))))) {
NGCCHandler h = new attributeUses(this, super._source, $runtime, 241, result);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 14:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action1();
$_ngcc_current_state = 13;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 4:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 244, null,AnnotationContext.ATTRIBUTE_GROUP);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 3;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 6:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 246, fa);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
if(($ai = $runtime.getAttributeIndex("","id"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 6;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 3:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
NGCCHandler h = new attributeUses(this, super._source, $runtime, 241, result);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 4:
{
$_ngcc_current_state = 3;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 13:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 12;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
if(($__uri.equals("") && $__local.equals("id"))) {
$_ngcc_current_state = 9;
}
else {
$_ngcc_current_state = 6;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 3:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
$_ngcc_current_state = 3;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
$_ngcc_current_state = 6;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 3:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 8:
{
if(($__uri.equals("") && $__local.equals("id"))) {
$_ngcc_current_state = 6;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 11:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 7;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 4:
{
$_ngcc_current_state = 3;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 13:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
case 7:
{
if(($ai = $runtime.getAttributeIndex("","id"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 6;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 12:
{
name = WhiteSpaceProcessor.collapse($value);
$_ngcc_current_state = 11;
}
break;
case 9:
{
$_ngcc_current_state = 8;
}
break;
case 3:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
break;
case 4:
{
$_ngcc_current_state = 3;
$runtime.sendText(super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 241:
{
$_ngcc_current_state = 1;
}
break;
case 246:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 4;
}
break;
case 244:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 3;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private AttGroupDeclImpl result;
private Locator locator;
}

View File

@@ -0,0 +1,962 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class attributeUses extends NGCCHandler {
private String use;
private AttributesHolder owner;
private ForeignAttributesImpl fa;
private WildcardImpl wildcard;
private AnnotationImpl annotation;
private UName attDeclName;
private AttributeDeclImpl anonymousDecl;
private String defaultValue;
private String fixedValue;
private UName groupName;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public attributeUses(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, AttributesHolder _owner) {
super(source, parent, cookie);
$runtime = runtime;
this.owner = _owner;
$_ngcc_current_state = 5;
}
public attributeUses(NGCCRuntimeEx runtime, AttributesHolder _owner) {
this(null, runtime, runtime, -1, _owner);
}
private void action0()throws SAXException {
owner.setWildcard(wildcard);
}
private void action1()throws SAXException {
wloc = $runtime.copyLocator();
}
private void action2()throws SAXException {
owner.addAttGroup(new DelayedRef.AttGroup(
$runtime, locator, $runtime.currentSchema, groupName ));
}
private void action3()throws SAXException {
locator=$runtime.copyLocator();
}
private void action4()throws SAXException {
if("prohibited".equals(use))
owner.addProhibitedAttribute(attDeclName);
else
owner.addAttributeUse(attDeclName,
new AttributeUseImpl( $runtime.document, annotation,locator,fa,decl,
$runtime.createXmlString(defaultValue),
$runtime.createXmlString(fixedValue),
"required".equals(use)));
}
private void action5()throws SAXException {
decl = new DelayedRef.Attribute(
$runtime, locator, $runtime.currentSchema, attDeclName );
}
private void action6()throws SAXException {
decl = anonymousDecl;
attDeclName = new UName(
anonymousDecl.getTargetNamespace(),
anonymousDecl.getName());
defaultValue = null;
fixedValue = null;
}
private void action7()throws SAXException {
locator=$runtime.copyLocator();
use=null;
defaultValue=null;
fixedValue=null;
decl=null;
annotation=null;
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action7();
$_ngcc_current_state = 33;
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action3();
$_ngcc_current_state = 13;
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action1();
$_ngcc_current_state = 3;
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
}
}
break;
case 8:
{
action2();
$_ngcc_current_state = 7;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 3:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || (($ai = $runtime.getAttributeIndex("","namespace"))>=0 || ($ai = $runtime.getAttributeIndex("","processContents"))>=0))) {
NGCCHandler h = new wildcardBody(this, super._source, $runtime, 290, wloc);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 17:
{
if((($ai = $runtime.getAttributeIndex("","name"))>=0 || ($ai = $runtime.getAttributeIndex("","form"))>=0)) {
NGCCHandler h = new attributeDeclBody(this, super._source, $runtime, 315, locator,true,defaultValue,fixedValue);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($ai = $runtime.getAttributeIndex("","ref"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
}
break;
case 33:
{
if(($ai = $runtime.getAttributeIndex("","use"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 29;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 25:
{
if(($ai = $runtime.getAttributeIndex("","fixed"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 17;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 29:
{
if(($ai = $runtime.getAttributeIndex("","default"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 25;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 9:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 297, null,AnnotationContext.ATTRIBUTE_USE);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 8;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 16:
{
action4();
$_ngcc_current_state = 15;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 5:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action7();
$_ngcc_current_state = 33;
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action3();
$_ngcc_current_state = 13;
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","ref"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 19:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 308, null,AnnotationContext.ATTRIBUTE_USE);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 18;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 8:
{
action2();
$_ngcc_current_state = 7;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 3:
{
if(((($ai = $runtime.getAttributeIndex("","namespace"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute"))) || ((($ai = $runtime.getAttributeIndex("","processContents"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute"))))) {
NGCCHandler h = new wildcardBody(this, super._source, $runtime, 290, wloc);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 17:
{
if(((($ai = $runtime.getAttributeIndex("","name"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))) || (($ai = $runtime.getAttributeIndex("","form"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))))) {
NGCCHandler h = new attributeDeclBody(this, super._source, $runtime, 315, locator,true,defaultValue,fixedValue);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
if(($ai = $runtime.getAttributeIndex("","ref"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
}
break;
case 33:
{
if(($ai = $runtime.getAttributeIndex("","use"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 29;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 15:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 25:
{
if(($ai = $runtime.getAttributeIndex("","fixed"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 17;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 29:
{
if(($ai = $runtime.getAttributeIndex("","default"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 25;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 9:
{
$_ngcc_current_state = 8;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 16:
{
action4();
$_ngcc_current_state = 15;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","ref"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 7:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 19:
{
$_ngcc_current_state = 18;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 18:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 306, null);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 8:
{
action2();
$_ngcc_current_state = 7;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 3:
{
if((($__uri.equals("") && $__local.equals("namespace")) || ($__uri.equals("") && $__local.equals("processContents")))) {
NGCCHandler h = new wildcardBody(this, super._source, $runtime, 290, wloc);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 17:
{
if((($__uri.equals("") && $__local.equals("name")) || ($__uri.equals("") && $__local.equals("form")))) {
NGCCHandler h = new attributeDeclBody(this, super._source, $runtime, 315, locator,true,defaultValue,fixedValue);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
if(($__uri.equals("") && $__local.equals("ref"))) {
$_ngcc_current_state = 22;
}
else {
unexpectedEnterAttribute($__qname);
}
}
}
break;
case 33:
{
if(($__uri.equals("") && $__local.equals("use"))) {
$_ngcc_current_state = 35;
}
else {
$_ngcc_current_state = 29;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 25:
{
if(($__uri.equals("") && $__local.equals("fixed"))) {
$_ngcc_current_state = 27;
}
else {
$_ngcc_current_state = 17;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 29:
{
if(($__uri.equals("") && $__local.equals("default"))) {
$_ngcc_current_state = 31;
}
else {
$_ngcc_current_state = 25;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 9:
{
$_ngcc_current_state = 8;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 16:
{
action4();
$_ngcc_current_state = 15;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 13:
{
if(($__uri.equals("") && $__local.equals("ref"))) {
$_ngcc_current_state = 12;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 19:
{
$_ngcc_current_state = 18;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 8:
{
action2();
$_ngcc_current_state = 7;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 34:
{
if(($__uri.equals("") && $__local.equals("use"))) {
$_ngcc_current_state = 29;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 26:
{
if(($__uri.equals("") && $__local.equals("fixed"))) {
$_ngcc_current_state = 17;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 11:
{
if(($__uri.equals("") && $__local.equals("ref"))) {
$_ngcc_current_state = 9;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 33:
{
$_ngcc_current_state = 29;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 21:
{
if(($__uri.equals("") && $__local.equals("ref"))) {
$_ngcc_current_state = 19;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 25:
{
$_ngcc_current_state = 17;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 30:
{
if(($__uri.equals("") && $__local.equals("default"))) {
$_ngcc_current_state = 25;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 29:
{
$_ngcc_current_state = 25;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 9:
{
$_ngcc_current_state = 8;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 16:
{
action4();
$_ngcc_current_state = 15;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 19:
{
$_ngcc_current_state = 18;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 31:
{
defaultValue = $value;
$_ngcc_current_state = 30;
}
break;
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendText(super._cookie, $value);
}
break;
case 8:
{
action2();
$_ngcc_current_state = 7;
$runtime.sendText(super._cookie, $value);
}
break;
case 3:
{
if(($ai = $runtime.getAttributeIndex("","processContents"))>=0) {
NGCCHandler h = new wildcardBody(this, super._source, $runtime, 290, wloc);
spawnChildFromText(h, $value);
}
else {
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
NGCCHandler h = new wildcardBody(this, super._source, $runtime, 290, wloc);
spawnChildFromText(h, $value);
}
}
}
break;
case 17:
{
if(($ai = $runtime.getAttributeIndex("","form"))>=0) {
NGCCHandler h = new attributeDeclBody(this, super._source, $runtime, 315, locator,true,defaultValue,fixedValue);
spawnChildFromText(h, $value);
}
else {
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
NGCCHandler h = new attributeDeclBody(this, super._source, $runtime, 315, locator,true,defaultValue,fixedValue);
spawnChildFromText(h, $value);
}
else {
if(($ai = $runtime.getAttributeIndex("","ref"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
}
}
break;
case 33:
{
if(($ai = $runtime.getAttributeIndex("","use"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 29;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 25:
{
if(($ai = $runtime.getAttributeIndex("","fixed"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 17;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 22:
{
NGCCHandler h = new qname(this, super._source, $runtime, 311);
spawnChildFromText(h, $value);
}
break;
case 29:
{
if(($ai = $runtime.getAttributeIndex("","default"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 25;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 12:
{
NGCCHandler h = new qname(this, super._source, $runtime, 300);
spawnChildFromText(h, $value);
}
break;
case 35:
{
use = $value;
$_ngcc_current_state = 34;
}
break;
case 27:
{
fixedValue = $value;
$_ngcc_current_state = 26;
}
break;
case 9:
{
$_ngcc_current_state = 8;
$runtime.sendText(super._cookie, $value);
}
break;
case 16:
{
action4();
$_ngcc_current_state = 15;
$runtime.sendText(super._cookie, $value);
}
break;
case 5:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
case 13:
{
if(($ai = $runtime.getAttributeIndex("","ref"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 19:
{
$_ngcc_current_state = 18;
$runtime.sendText(super._cookie, $value);
}
break;
case 0:
{
revertToParentFromText(this, super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 300:
{
groupName = ((UName)$__result__);
$_ngcc_current_state = 11;
}
break;
case 297:
{
$_ngcc_current_state = 8;
}
break;
case 306:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 16;
}
break;
case 290:
{
wildcard = ((WildcardImpl)$__result__);
action0();
$_ngcc_current_state = 2;
}
break;
case 315:
{
anonymousDecl = ((AttributeDeclImpl)$__result__);
action6();
$_ngcc_current_state = 16;
}
break;
case 311:
{
attDeclName = ((UName)$__result__);
action5();
$_ngcc_current_state = 21;
}
break;
case 308:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 18;
}
break;
}
}
public boolean accepted() {
return((($_ngcc_current_state == 0) || (($_ngcc_current_state == 1) || ($_ngcc_current_state == 5))));
}
private Ref.Attribute decl;
private Locator wloc; // locator for wildcards
private Locator locator;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,256 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class complexType_complexContent_body extends NGCCHandler {
private AttributesHolder owner;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public complexType_complexContent_body(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, AttributesHolder _owner) {
super(source, parent, cookie);
$runtime = runtime;
this.owner = _owner;
$_ngcc_current_state = 2;
}
public complexType_complexContent_body(NGCCRuntimeEx runtime, AttributesHolder _owner) {
this(null, runtime, runtime, -1, _owner);
}
private void action0()throws SAXException {
if(particle==null)
particle = $runtime.parser.schemaSet.empty;
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("anyAttribute")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attribute"))))) {
NGCCHandler h = new attributeUses(this, super._source, $runtime, 1, owner);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
NGCCHandler h = new attributeUses(this, super._source, $runtime, 1, owner);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(particle, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 2:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("element")) || (((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("any")))))) {
NGCCHandler h = new particle(this, super._source, $runtime, 3);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
NGCCHandler h = new attributeUses(this, super._source, $runtime, 1, owner);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveElement(particle, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
NGCCHandler h = new attributeUses(this, super._source, $runtime, 1, owner);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(particle, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
NGCCHandler h = new attributeUses(this, super._source, $runtime, 1, owner);
spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(particle, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 1:
{
NGCCHandler h = new attributeUses(this, super._source, $runtime, 1, owner);
spawnChildFromText(h, $value);
}
break;
case 0:
{
revertToParentFromText(particle, super._cookie, $value);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 1:
{
action0();
$_ngcc_current_state = 0;
}
break;
case 3:
{
particle = ((ParticleImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private ContentTypeImpl particle;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,184 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class erSet extends NGCCHandler {
private String v;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public erSet(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 1;
}
public erSet(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
case 1:
{
v = $value;
$_ngcc_current_state = 0;
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private Integer makeResult() {
if(v==null) return new Integer($runtime.finalDefault);
if(v.indexOf("#all")!=-1)
return new Integer(XSType.EXTENSION|XSType.RESTRICTION);
int r = 0;
if(v.indexOf("extension")!=-1) r|=XSType.EXTENSION;
if(v.indexOf("restriction")!=-1) r|=XSType.RESTRICTION;
return new Integer(r);
}
}

View File

@@ -0,0 +1,186 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class ersSet extends NGCCHandler {
private String v;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public ersSet(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 1;
}
public ersSet(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
case 1:
{
v = $value;
$_ngcc_current_state = 0;
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private Integer makeResult() {
if(v==null) return new Integer($runtime.blockDefault);
if(v.indexOf("#all")!=-1)
return new Integer(
XSType.EXTENSION|XSType.RESTRICTION|XSType.SUBSTITUTION);
int r = 0;
if(v.indexOf("extension")!=-1) r|=XSType.EXTENSION;
if(v.indexOf("restriction")!=-1) r|=XSType.RESTRICTION;
if(v.indexOf("substitution")!=-1) r|=XSType.SUBSTITUTION;
return new Integer(r);
}
}

View File

@@ -0,0 +1,401 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class facet extends NGCCHandler {
private AnnotationImpl annotation;
private String fixed;
private String value;
private ForeignAttributesImpl fa;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public facet(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 12;
}
public facet(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
result = new FacetImpl( $runtime.document,
annotation, locator, fa, $localName/*name of the facet*/,
$runtime.createXmlString(value), $runtime.parseBoolean(fixed) );
}
private void action1()throws SAXException {
locator=$runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 12:
{
if((((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action1();
$_ngcc_current_state = 11;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 4:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 230, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","fixed"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 4;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","value"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 228, null,AnnotationContext.SIMPLETYPE_DECL);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
if((((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 230, fa);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","fixed"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 4;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 1:
{
if((((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
action0();
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","value"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 5:
{
if(($__uri.equals("") && $__local.equals("fixed"))) {
$_ngcc_current_state = 7;
}
else {
$_ngcc_current_state = 4;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 11:
{
if(($__uri.equals("") && $__local.equals("value"))) {
$_ngcc_current_state = 10;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 5:
{
$_ngcc_current_state = 4;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 9:
{
if(($__uri.equals("") && $__local.equals("value"))) {
$_ngcc_current_state = 5;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($__uri.equals("") && $__local.equals("fixed"))) {
$_ngcc_current_state = 4;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 5:
{
if(($ai = $runtime.getAttributeIndex("","fixed"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 4;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 7:
{
fixed = $value;
$_ngcc_current_state = 6;
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","value"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 10:
{
value = $value;
$_ngcc_current_state = 9;
}
break;
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 230:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 2;
}
break;
case 228:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private FacetImpl result;
private Locator locator;
}

View File

@@ -0,0 +1,169 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class foreignAttributes extends NGCCHandler {
private ForeignAttributesImpl current;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public foreignAttributes(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, ForeignAttributesImpl _current) {
super(source, parent, cookie);
$runtime = runtime;
this.current = _current;
$_ngcc_current_state = 0;
}
public foreignAttributes(NGCCRuntimeEx runtime, ForeignAttributesImpl _current) {
this(null, runtime, runtime, -1, _current);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
ForeignAttributesImpl makeResult() {
return $runtime.parseForeignAttributes(current);
}
}

View File

@@ -0,0 +1,444 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import com.sun.xml.internal.bind.WhiteSpaceProcessor;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.parser.*;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
class group extends NGCCHandler {
private AnnotationImpl annotation;
private String name;
private ModelGroupImpl term;
private ForeignAttributesImpl fa;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public group(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 15;
}
public group(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
result = new ModelGroupDeclImpl( $runtime.document,
annotation, loc, fa,
$runtime.currentSchema.getTargetNamespace(),
name,
term
);
}
private void action1()throws SAXException {
mloc = $runtime.copyLocator();
compositorName = $localName;
}
private void action2()throws SAXException {
loc = $runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 10:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 5:
{
if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 357, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","ID"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 10;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 6:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 359, null,AnnotationContext.MODELGROUP_DECL);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 5;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 4:
{
if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence")))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
$_ngcc_current_state = 3;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 15:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action2();
$_ngcc_current_state = 11;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 3:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("element")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("any")) || ((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence")))))))) {
NGCCHandler h = new modelGroupBody(this, super._source, $runtime, 355, mloc,compositorName);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 10:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","ID"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 10;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
action0();
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 6:
{
$_ngcc_current_state = 5;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence")))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 3:
{
if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence")))) {
NGCCHandler h = new modelGroupBody(this, super._source, $runtime, 355, mloc,compositorName);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 10:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 9;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 11:
{
if(($__uri.equals("") && $__local.equals("ID"))) {
$_ngcc_current_state = 13;
}
else {
$_ngcc_current_state = 10;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 6:
{
$_ngcc_current_state = 5;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 11:
{
$_ngcc_current_state = 10;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
$_ngcc_current_state = 5;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 12:
{
if(($__uri.equals("") && $__local.equals("ID"))) {
$_ngcc_current_state = 10;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 8:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 6;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 10:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","ID"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 10;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 6:
{
$_ngcc_current_state = 5;
$runtime.sendText(super._cookie, $value);
}
break;
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
case 9:
{
name = WhiteSpaceProcessor.collapse($value);
$_ngcc_current_state = 8;
}
break;
case 13:
{
$_ngcc_current_state = 12;
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 357:
{
fa = ((ForeignAttributesImpl)$__result__);
action1();
$_ngcc_current_state = 4;
}
break;
case 359:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 5;
}
break;
case 355:
{
term = ((ModelGroupImpl)$__result__);
$_ngcc_current_state = 2;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private ModelGroupDeclImpl result;
private Locator loc,mloc;
private String compositorName;
}

View File

@@ -0,0 +1,590 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import com.sun.xml.internal.bind.WhiteSpaceProcessor;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import com.sun.xml.internal.xsom.parser.*;
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
class identityConstraint extends NGCCHandler {
private String name;
private UName ref;
private ForeignAttributesImpl fa;
private AnnotationImpl ann;
private XPathImpl field;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public identityConstraint(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 18;
}
public identityConstraint(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
fields.add(field);
}
private void action1()throws SAXException {
refer = new DelayedRef.IdentityConstraint(
$runtime, $runtime.copyLocator(), $runtime.currentSchema, ref );
}
private void action2()throws SAXException {
if($localName.equals("key"))
category = XSIdentityConstraint.KEY;
else
if($localName.equals("keyref"))
category = XSIdentityConstraint.KEYREF;
else
if($localName.equals("unique"))
category = XSIdentityConstraint.UNIQUE;
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 16:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
$_ngcc_current_state = 3;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 17:
{
if((($ai = $runtime.getAttributeIndex("","name"))>=0 && (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 7:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
$_ngcc_current_state = 6;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 18:
{
if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("key")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("keyref"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("unique")))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action2();
$_ngcc_current_state = 17;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 3:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
NGCCHandler h = new xpath(this, super._source, $runtime, 270);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 4:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
$_ngcc_current_state = 3;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 8:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 277, null,AnnotationContext.IDENTITY_CONSTRAINT);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 7;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 10:
{
if(($ai = $runtime.getAttributeIndex("","refer"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 8;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 6:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
NGCCHandler h = new xpath(this, super._source, $runtime, 274);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 5:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 4;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 16:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 1:
{
if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("key")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("keyref"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("unique")))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 17:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 3:
{
if((($ai = $runtime.getAttributeIndex("","xpath"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field")))) {
NGCCHandler h = new xpath(this, super._source, $runtime, 270);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 10:
{
if(($ai = $runtime.getAttributeIndex("","refer"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 8;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 6:
{
if((($ai = $runtime.getAttributeIndex("","xpath"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector")))) {
NGCCHandler h = new xpath(this, super._source, $runtime, 274);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 16:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 15;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 17:
{
if(($__uri.equals("") && $__local.equals("name"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 3:
{
if(($__uri.equals("") && $__local.equals("xpath"))) {
NGCCHandler h = new xpath(this, super._source, $runtime, 270);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 10:
{
if(($__uri.equals("") && $__local.equals("refer"))) {
$_ngcc_current_state = 12;
}
else {
$_ngcc_current_state = 8;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 6:
{
if(($__uri.equals("") && $__local.equals("xpath"))) {
NGCCHandler h = new xpath(this, super._source, $runtime, 274);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 14:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 10;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 10:
{
$_ngcc_current_state = 8;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 11:
{
if(($__uri.equals("") && $__local.equals("refer"))) {
$_ngcc_current_state = 8;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 15:
{
name = WhiteSpaceProcessor.collapse($value);
$_ngcc_current_state = 14;
}
break;
case 16:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
case 12:
{
NGCCHandler h = new qname(this, super._source, $runtime, 280);
spawnChildFromText(h, $value);
}
break;
case 17:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
spawnChildFromText(h, $value);
}
}
break;
case 3:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
NGCCHandler h = new xpath(this, super._source, $runtime, 270);
spawnChildFromText(h, $value);
}
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendText(super._cookie, $value);
}
break;
case 10:
{
if(($ai = $runtime.getAttributeIndex("","refer"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 8;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 6:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
NGCCHandler h = new xpath(this, super._source, $runtime, 274);
spawnChildFromText(h, $value);
}
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 270:
{
field = ((XPathImpl)$__result__);
action0();
$_ngcc_current_state = 2;
}
break;
case 287:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 16;
}
break;
case 280:
{
ref = ((UName)$__result__);
action1();
$_ngcc_current_state = 11;
}
break;
case 277:
{
ann = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 7;
}
break;
case 274:
{
selector = ((XPathImpl)$__result__);
$_ngcc_current_state = 5;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private short category;
private List fields = new ArrayList();
private XPathImpl selector;
private DelayedRef.IdentityConstraint refer = null;
private IdentityConstraintImpl makeResult() {
return new IdentityConstraintImpl($runtime.document,ann,$runtime.copyLocator(),fa,
category,name,selector,fields,refer);
}
}

View File

@@ -0,0 +1,374 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class importDecl extends NGCCHandler {
private String ns;
private String schemaLocation;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public importDecl(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 12;
}
public importDecl(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
if(ns==null) ns="";
$runtime.importSchema( ns,schemaLocation );
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 8:
{
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 4;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 12:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("import"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
$_ngcc_current_state = 8;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 340, null,AnnotationContext.SCHEMA);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 8:
{
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 4;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("import"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
action0();
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 4:
{
if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
$_ngcc_current_state = 6;
}
else {
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 8:
{
if(($__uri.equals("") && $__local.equals("namespace"))) {
$_ngcc_current_state = 10;
}
else {
$_ngcc_current_state = 4;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 9:
{
if(($__uri.equals("") && $__local.equals("namespace"))) {
$_ngcc_current_state = 4;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 8:
{
$_ngcc_current_state = 4;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
$_ngcc_current_state = 2;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 4:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 8:
{
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 4;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 10:
{
ns = $value;
$_ngcc_current_state = 9;
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
case 0:
{
revertToParentFromText(this, super._cookie, $value);
}
break;
case 6:
{
schemaLocation = $value;
$_ngcc_current_state = 5;
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 340:
{
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
}

View File

@@ -0,0 +1,288 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class includeDecl extends NGCCHandler {
private String schemaLocation;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public includeDecl(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 7;
}
public includeDecl(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
$runtime.includeSchema( schemaLocation );
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 372, null,AnnotationContext.SCHEMA);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 7:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("include"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
$_ngcc_current_state = 6;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 6:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("include"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
action0();
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
$_ngcc_current_state = 5;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
$_ngcc_current_state = 2;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
case 0:
{
revertToParentFromText(this, super._cookie, $value);
}
break;
case 5:
{
schemaLocation = $value;
$_ngcc_current_state = 4;
}
break;
case 6:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 372:
{
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
}

View File

@@ -0,0 +1,370 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Vector;
class modelGroupBody extends NGCCHandler {
private AnnotationImpl annotation;
private String compositorName;
private Locator locator;
private ParticleImpl childParticle;
private ForeignAttributesImpl fa;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public modelGroupBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, String _compositorName) {
super(source, parent, cookie);
$runtime = runtime;
this.locator = _locator;
this.compositorName = _compositorName;
$_ngcc_current_state = 6;
}
public modelGroupBody(NGCCRuntimeEx runtime, Locator _locator, String _compositorName) {
this(null, runtime, runtime, -1, _locator, _compositorName);
}
private void action0()throws SAXException {
XSModelGroup.Compositor compositor = null;
if(compositorName.equals("all")) compositor = XSModelGroup.ALL;
if(compositorName.equals("sequence")) compositor = XSModelGroup.SEQUENCE;
if(compositorName.equals("choice")) compositor = XSModelGroup.CHOICE;
if(compositor==null)
throw new InternalError("unable to process "+compositorName);
result = new ModelGroupImpl( $runtime.document, annotation, locator, fa, compositor,
(ParticleImpl[])particles.toArray(new ParticleImpl[0]));
}
private void action1()throws SAXException {
particles.add(childParticle);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 4:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 174, null,AnnotationContext.MODELGROUP);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 2:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("element")) || (((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("any")))))) {
NGCCHandler h = new particle(this, super._source, $runtime, 171);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 6:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("element")) || (((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("any"))))))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 176, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 176, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 1:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("element")) || (((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("all")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("choice"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("sequence"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("any")))))) {
NGCCHandler h = new particle(this, super._source, $runtime, 170);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
action0();
$_ngcc_current_state = 0;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 176, null);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
break;
case 1:
{
action0();
$_ngcc_current_state = 0;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 176, null);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
break;
case 1:
{
action0();
$_ngcc_current_state = 0;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 176, null);
spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
}
break;
case 1:
{
action0();
$_ngcc_current_state = 0;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
case 6:
{
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 176, null);
spawnChildFromText(h, $value);
}
break;
case 1:
{
action0();
$_ngcc_current_state = 0;
$runtime.sendText(super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 174:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 2;
}
break;
case 176:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 4;
}
break;
case 171:
{
childParticle = ((ParticleImpl)$__result__);
action1();
$_ngcc_current_state = 1;
}
break;
case 170:
{
childParticle = ((ParticleImpl)$__result__);
action1();
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return((($_ngcc_current_state == 1) || (($_ngcc_current_state == 2) || (($_ngcc_current_state == 4) || ($_ngcc_current_state == 0)))));
}
private ModelGroupImpl result;
private final List particles = new ArrayList();
}

View File

@@ -0,0 +1,477 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import com.sun.xml.internal.bind.WhiteSpaceProcessor;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.parser.*;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
class notation extends NGCCHandler {
private String name;
private String pub;
private ForeignAttributesImpl fa;
private String sys;
private AnnotationImpl ann;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public notation(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 16;
}
public notation(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
loc = $runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 209, null,AnnotationContext.NOTATION);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 16:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("notation"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action0();
$_ngcc_current_state = 15;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 14:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 15:
{
if((($ai = $runtime.getAttributeIndex("","name"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 224, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 4:
{
if(($ai = $runtime.getAttributeIndex("","system"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 8:
{
if(($ai = $runtime.getAttributeIndex("","public"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 4;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 14:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 15:
{
if((($ai = $runtime.getAttributeIndex("","name"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("notation")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 224, null);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 4:
{
if(($ai = $runtime.getAttributeIndex("","system"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("notation"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 8:
{
if(($ai = $runtime.getAttributeIndex("","public"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 4;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 14:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 13;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 15:
{
if(($__uri.equals("") && $__local.equals("name"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 224, null);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 4:
{
if(($__uri.equals("") && $__local.equals("system"))) {
$_ngcc_current_state = 6;
}
else {
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 8:
{
if(($__uri.equals("") && $__local.equals("public"))) {
$_ngcc_current_state = 10;
}
else {
$_ngcc_current_state = 4;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 9:
{
if(($__uri.equals("") && $__local.equals("public"))) {
$_ngcc_current_state = 4;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 12:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 8;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 5:
{
if(($__uri.equals("") && $__local.equals("system"))) {
$_ngcc_current_state = 2;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 4:
{
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 8:
{
$_ngcc_current_state = 4;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
case 10:
{
pub = $value;
$_ngcc_current_state = 9;
}
break;
case 14:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 15:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 224, null);
spawnChildFromText(h, $value);
}
}
break;
case 4:
{
if(($ai = $runtime.getAttributeIndex("","system"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 8:
{
if(($ai = $runtime.getAttributeIndex("","public"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 4;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 13:
{
name = WhiteSpaceProcessor.collapse($value);
$_ngcc_current_state = 12;
}
break;
case 6:
{
sys = $value;
$_ngcc_current_state = 5;
}
break;
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 209:
{
ann = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
case 224:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 14;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
private Locator loc;
private XSNotation makeResult() {
return new NotationImpl( $runtime.document,ann,loc,fa,name,pub,sys);
}
}

View File

@@ -0,0 +1,326 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
import java.math.BigInteger;
class occurs extends NGCCHandler {
private String v;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public occurs(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 5;
}
public occurs(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
min = new BigInteger(v);
}
private void action1()throws SAXException {
max=BigInteger.valueOf(-1);
}
private void action2()throws SAXException {
max = new BigInteger(v);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($ai = $runtime.getAttributeIndex("","minOccurs"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","maxOccurs"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($ai = $runtime.getAttributeIndex("","minOccurs"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 0;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","maxOccurs"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($__uri.equals("") && $__local.equals("minOccurs"))) {
$_ngcc_current_state = 3;
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 0:
{
revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
if(($__uri.equals("") && $__local.equals("maxOccurs"))) {
$_ngcc_current_state = 7;
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
if(($__uri.equals("") && $__local.equals("minOccurs"))) {
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 5:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($__uri.equals("") && $__local.equals("maxOccurs"))) {
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 1:
{
if(($ai = $runtime.getAttributeIndex("","minOccurs"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 0;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 0:
{
revertToParentFromText(this, super._cookie, $value);
}
break;
case 3:
{
v = $value;
$_ngcc_current_state = 2;
action0();
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","maxOccurs"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 7:
{
if($value.equals("unbounded")) {
$_ngcc_current_state = 6;
action1();
}
else {
v = $value;
$_ngcc_current_state = 6;
action2();
}
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
}
}
public boolean accepted() {
return((($_ngcc_current_state == 5) || (($_ngcc_current_state == 0) || ($_ngcc_current_state == 1))));
}
BigInteger max = BigInteger.valueOf(1);
BigInteger min = BigInteger.valueOf(1);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import com.sun.xml.internal.bind.WhiteSpaceProcessor;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
class qname extends NGCCHandler {
private String qvalue;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public qname(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 1;
}
public qname(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement($runtime.parseUName(qvalue), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement($runtime.parseUName(qvalue), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute($runtime.parseUName(qvalue), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute($runtime.parseUName(qvalue), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText($runtime.parseUName(qvalue), super._cookie, $value);
}
break;
case 1:
{
qvalue = WhiteSpaceProcessor.collapse($value);
$_ngcc_current_state = 0;
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
}

View File

@@ -0,0 +1,178 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class qualification extends NGCCHandler {
private String text;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public qualification(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 1;
}
public qualification(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(new Boolean(text.trim().equals("qualified")), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(new Boolean(text.trim().equals("qualified")), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(new Boolean(text.trim().equals("qualified")), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(new Boolean(text.trim().equals("qualified")), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(new Boolean(text.trim().equals("qualified")), super._cookie, $value);
}
break;
case 1:
{
if($value.equals("qualified")) {
text = $value;
$_ngcc_current_state = 0;
}
else {
if($value.equals("unqualified")) {
text = $value;
$_ngcc_current_state = 0;
}
}
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
}

View File

@@ -0,0 +1,452 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class redefine extends NGCCHandler {
private String schemaLocation;
private ModelGroupDeclImpl newGrp;
private AttGroupDeclImpl newAg;
private SimpleTypeImpl newSt;
private ComplexTypeImpl newCt;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public redefine(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 15;
}
public redefine(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
XSAttGroupDecl oldAg = $runtime.currentSchema.getAttGroupDecl(newAg.getName());
if(oldAg==null) {
$runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_ATTRIBUTEGROUP,newAg.getName()) );
} else {
newAg.redefine((AttGroupDeclImpl)oldAg);
$runtime.currentSchema.addAttGroupDecl(newAg,true);
}
}
private void action1()throws SAXException {
XSModelGroupDecl oldGrp = $runtime.currentSchema.getModelGroupDecl(newGrp.getName());
if(oldGrp==null) {
$runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_MODELGROUP,newGrp.getName()) );
} else {
newGrp.redefine((ModelGroupDeclImpl)oldGrp);
$runtime.currentSchema.addModelGroupDecl(newGrp,true);
}
}
private void action2()throws SAXException {
XSComplexType oldCt = $runtime.currentSchema.getComplexType(newCt.getName());
if(oldCt==null) {
$runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_COMPLEXTYPE,newCt.getName()) );
} else {
newCt.redefine((ComplexTypeImpl)oldCt);
$runtime.currentSchema.addComplexType(newCt,true);
}
}
private void action3()throws SAXException {
XSSimpleType oldSt = $runtime.currentSchema.getSimpleType(newSt.getName());
if(oldSt==null) {
$runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_SIMPLETYPE,newSt.getName()) );
} else {
newSt.redefine((SimpleTypeImpl)oldSt);
$runtime.currentSchema.addSimpleType(newSt,true);
}
}
private void action4()throws SAXException {
$runtime.includeSchema( schemaLocation );
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 684, null,AnnotationContext.SCHEMA);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
NGCCHandler h = new simpleType(this, super._source, $runtime, 685);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("complexType"))) {
NGCCHandler h = new complexType(this, super._source, $runtime, 686);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
NGCCHandler h = new group(this, super._source, $runtime, 687);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
NGCCHandler h = new attributeGroupDecl(this, super._source, $runtime, 688);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
}
}
}
}
break;
case 14:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 689, null,AnnotationContext.SCHEMA);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
NGCCHandler h = new simpleType(this, super._source, $runtime, 690);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("complexType"))) {
NGCCHandler h = new complexType(this, super._source, $runtime, 691);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
NGCCHandler h = new group(this, super._source, $runtime, 692);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
NGCCHandler h = new attributeGroupDecl(this, super._source, $runtime, 693);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
}
}
}
}
break;
case 15:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("redefine"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
$_ngcc_current_state = 14;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("redefine"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 14:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 14:
{
if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
$_ngcc_current_state = 13;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
}
break;
case 12:
{
if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
$_ngcc_current_state = 2;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromText(this, super._cookie, $value);
}
break;
case 14:
{
if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
case 2:
{
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
break;
case 13:
{
schemaLocation = $value;
$_ngcc_current_state = 12;
action4();
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 689:
{
$_ngcc_current_state = 1;
}
break;
case 690:
{
newSt = ((SimpleTypeImpl)$__result__);
action3();
$_ngcc_current_state = 1;
}
break;
case 691:
{
newCt = ((ComplexTypeImpl)$__result__);
action2();
$_ngcc_current_state = 1;
}
break;
case 692:
{
newGrp = ((ModelGroupDeclImpl)$__result__);
action1();
$_ngcc_current_state = 1;
}
break;
case 693:
{
newAg = ((AttGroupDeclImpl)$__result__);
action0();
$_ngcc_current_state = 1;
}
break;
case 684:
{
$_ngcc_current_state = 1;
}
break;
case 685:
{
newSt = ((SimpleTypeImpl)$__result__);
action3();
$_ngcc_current_state = 1;
}
break;
case 686:
{
newCt = ((ComplexTypeImpl)$__result__);
action2();
$_ngcc_current_state = 1;
}
break;
case 687:
{
newGrp = ((ModelGroupDeclImpl)$__result__);
action1();
$_ngcc_current_state = 1;
}
break;
case 688:
{
newAg = ((AttGroupDeclImpl)$__result__);
action0();
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
}

View File

@@ -0,0 +1,503 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import com.sun.xml.internal.bind.WhiteSpaceProcessor;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.parser.*;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
class simpleType extends NGCCHandler {
private AnnotationImpl annotation;
private String name;
private ForeignAttributesImpl fa;
private String finalValue;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public simpleType(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 19;
}
public simpleType(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
private void action0()throws SAXException {
finalSet = makeFinalSet(finalValue);
}
private void action1()throws SAXException {
locator=$runtime.copyLocator();
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 15:
{
if(($ai = $runtime.getAttributeIndex("","final"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 11;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 10;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 19:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
$runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
action1();
$_ngcc_current_state = 15;
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 8:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 89, null,AnnotationContext.SIMPLETYPE_DECL);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 7;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 10:
{
if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("union")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("list")))))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 91, fa);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 7:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 0:
{
revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 2:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction"))) {
NGCCHandler h = new SimpleType_Restriction(this, super._source, $runtime, 85, annotation,locator,fa,name,finalSet);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("list"))) {
NGCCHandler h = new SimpleType_List(this, super._source, $runtime, 86, annotation,locator,fa,name,finalSet);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("union"))) {
NGCCHandler h = new SimpleType_Union(this, super._source, $runtime, 80, annotation,locator,fa,name,finalSet);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 15:
{
if(($ai = $runtime.getAttributeIndex("","final"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 11;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 10;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
$runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 15:
{
if(($__uri.equals("") && $__local.equals("final"))) {
$_ngcc_current_state = 17;
}
else {
$_ngcc_current_state = 11;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 11:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 13;
}
else {
$_ngcc_current_state = 10;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 15:
{
$_ngcc_current_state = 11;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 11:
{
$_ngcc_current_state = 10;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 7:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 12:
{
if(($__uri.equals("") && $__local.equals("name"))) {
$_ngcc_current_state = 10;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 16:
{
if(($__uri.equals("") && $__local.equals("final"))) {
$_ngcc_current_state = 11;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 0:
{
revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 13:
{
name = WhiteSpaceProcessor.collapse($value);
$_ngcc_current_state = 12;
}
break;
case 15:
{
if(($ai = $runtime.getAttributeIndex("","final"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 11;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 11:
{
if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 10;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 8:
{
$_ngcc_current_state = 7;
$runtime.sendText(super._cookie, $value);
}
break;
case 7:
{
action0();
$_ngcc_current_state = 2;
$runtime.sendText(super._cookie, $value);
}
break;
case 17:
{
finalValue = $value;
$_ngcc_current_state = 16;
}
break;
case 0:
{
revertToParentFromText(result, super._cookie, $value);
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 89:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 7;
}
break;
case 91:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 8;
}
break;
case 85:
{
result = ((RestrictionSimpleTypeImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
case 86:
{
result = ((ListSimpleTypeImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
case 80:
{
result = ((UnionSimpleTypeImpl)$__result__);
$_ngcc_current_state = 1;
}
break;
}
}
public boolean accepted() {
return(($_ngcc_current_state == 0));
}
/** computed simple type object */
private SimpleTypeImpl result;
private Locator locator;
private Set finalSet;
private Set makeFinalSet(String finalValue) {
if(finalValue==null)
return Collections.EMPTY_SET;
Set s = new HashSet();
StringTokenizer tokens = new StringTokenizer(finalValue);
while(tokens.hasMoreTokens()) {
String token = tokens.nextToken();
if(token.equals("#all")) {
s.add(XSVariety.ATOMIC);
s.add(XSVariety.UNION);
s.add(XSVariety.LIST);
}
if(token.equals("list")) {
s.add(XSVariety.LIST);
}
if(token.equals("union")) {
s.add(XSVariety.UNION);
}
if(token.equals("restriction")) {
s.add(XSVariety.ATOMIC);
}
}
return s;
}
}

View File

@@ -0,0 +1,446 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.util.HashSet;
class wildcardBody extends NGCCHandler {
private AnnotationImpl annotation;
private Locator locator;
private String modeValue;
private String ns;
private ForeignAttributesImpl fa;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public wildcardBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator) {
super(source, parent, cookie);
$runtime = runtime;
this.locator = _locator;
$_ngcc_current_state = 10;
}
public wildcardBody(NGCCRuntimeEx runtime, Locator _locator) {
this(null, runtime, runtime, -1, _locator);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","processContents"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 9:
{
if((($ai = $runtime.getAttributeIndex("","namespace"))>=0 || ($ai = $runtime.getAttributeIndex("","processContents"))>=0)) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 10:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 411, null,AnnotationContext.WILDCARD);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 9;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 0;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","processContents"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
$_ngcc_current_state = 1;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 9:
{
if((($ai = $runtime.getAttributeIndex("","namespace"))>=0 || ($ai = $runtime.getAttributeIndex("","processContents"))>=0)) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
}
break;
case 10:
{
$_ngcc_current_state = 9;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
if(($__uri.equals("") && $__local.equals("namespace"))) {
$_ngcc_current_state = 3;
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 5:
{
if(($__uri.equals("") && $__local.equals("processContents"))) {
$_ngcc_current_state = 7;
}
else {
$_ngcc_current_state = 1;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
}
break;
case 9:
{
if((($__uri.equals("") && $__local.equals("namespace")) || ($__uri.equals("") && $__local.equals("processContents")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
}
break;
case 10:
{
$_ngcc_current_state = 9;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
$_ngcc_current_state = 1;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($__uri.equals("") && $__local.equals("processContents"))) {
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
case 9:
{
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
}
break;
case 10:
{
$_ngcc_current_state = 9;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 2:
{
if(($__uri.equals("") && $__local.equals("namespace"))) {
$_ngcc_current_state = 0;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 1:
{
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 0;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 3:
{
ns = $value;
$_ngcc_current_state = 2;
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","processContents"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
else {
$_ngcc_current_state = 1;
$runtime.sendText(super._cookie, $value);
}
}
break;
case 9:
{
if(($ai = $runtime.getAttributeIndex("","processContents"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromText(h, $value);
}
else {
if(($ai = $runtime.getAttributeIndex("","namespace"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromText(h, $value);
}
else {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 409, null);
spawnChildFromText(h, $value);
}
}
}
break;
case 10:
{
$_ngcc_current_state = 9;
$runtime.sendText(super._cookie, $value);
}
break;
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
case 7:
{
modeValue = $value;
$_ngcc_current_state = 6;
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 409:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 5;
}
break;
case 411:
{
annotation = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 9;
}
break;
}
}
public boolean accepted() {
return((($_ngcc_current_state == 0) || (($_ngcc_current_state == 5) || ($_ngcc_current_state == 1))));
}
private WildcardImpl makeResult() {
if(modeValue==null) modeValue="strict";
int mode=-1;
if(modeValue.equals("strict")) mode = XSWildcard.STRTICT;
if(modeValue.equals("lax")) mode = XSWildcard.LAX;
if(modeValue.equals("skip")) mode = XSWildcard.SKIP;
if(mode==-1) throw new InternalError();
if(ns==null || ns.equals("##any"))
return new WildcardImpl.Any( $runtime.document, annotation,locator,fa,mode);
if(ns.equals("##other"))
return new WildcardImpl.Other( $runtime.document,
annotation,locator,fa,
$runtime.currentSchema.getTargetNamespace(),mode);
StringTokenizer tokens = new StringTokenizer(ns);
HashSet s = new HashSet();
while(tokens.hasMoreTokens()) {
String ns = tokens.nextToken();
if(ns.equals("##local")) ns="";
if(ns.equals("##targetNamespace")) ns=$runtime.currentSchema.getTargetNamespace();
s.add(ns);
}
return new WildcardImpl.Finite( $runtime.document, annotation,locator,fa,s,mode);
}
}

View File

@@ -0,0 +1,316 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.*;
import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler;
import org.xml.sax.helpers.*;
import java.util.*;
import java.math.BigInteger;
class xpath extends NGCCHandler {
private String xpath;
private ForeignAttributesImpl fa;
private AnnotationImpl ann;
protected final NGCCRuntimeEx $runtime;
private int $_ngcc_current_state;
protected String $uri;
protected String $localName;
protected String $qname;
public final NGCCRuntime getRuntime() {
return($runtime);
}
public xpath(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
super(source, parent, cookie);
$runtime = runtime;
$_ngcc_current_state = 6;
}
public xpath(NGCCRuntimeEx runtime) {
this(null, runtime, runtime, -1);
}
public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
}
break;
case 6:
{
if((($ai = $runtime.getAttributeIndex("","xpath"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 77, null);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
case 1:
{
if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
NGCCHandler h = new annotation(this, super._source, $runtime, 72, null,AnnotationContext.XPATH);
spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
}
else {
$_ngcc_current_state = 0;
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
}
else {
unexpectedEnterElement($__qname);
}
}
break;
default:
{
unexpectedEnterElement($__qname);
}
break;
}
}
public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 77, null);
spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
}
else {
unexpectedLeaveElement($__qname);
}
}
break;
default:
{
unexpectedLeaveElement($__qname);
}
break;
}
}
public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 6:
{
if(($__uri.equals("") && $__local.equals("xpath"))) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 77, null);
spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 5:
{
if(($__uri.equals("") && $__local.equals("xpath"))) {
$_ngcc_current_state = 4;
}
else {
unexpectedEnterAttribute($__qname);
}
}
break;
default:
{
unexpectedEnterAttribute($__qname);
}
break;
}
}
public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
int $ai;
$uri = $__uri;
$localName = $__local;
$qname = $__qname;
switch($_ngcc_current_state) {
case 0:
{
revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
}
break;
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
}
break;
case 3:
{
if(($__uri.equals("") && $__local.equals("xpath"))) {
$_ngcc_current_state = 1;
}
else {
unexpectedLeaveAttribute($__qname);
}
}
break;
default:
{
unexpectedLeaveAttribute($__qname);
}
break;
}
}
public void text(String $value) throws SAXException {
int $ai;
switch($_ngcc_current_state) {
case 4:
{
xpath = $value;
$_ngcc_current_state = 3;
}
break;
case 0:
{
revertToParentFromText(makeResult(), super._cookie, $value);
}
break;
case 6:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 77, null);
spawnChildFromText(h, $value);
}
}
break;
case 1:
{
$_ngcc_current_state = 0;
$runtime.sendText(super._cookie, $value);
}
break;
case 5:
{
if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
$runtime.consumeAttribute($ai);
$runtime.sendText(super._cookie, $value);
}
}
break;
}
}
public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
switch($__cookie__) {
case 77:
{
fa = ((ForeignAttributesImpl)$__result__);
$_ngcc_current_state = 5;
}
break;
case 72:
{
ann = ((AnnotationImpl)$__result__);
$_ngcc_current_state = 0;
}
break;
}
}
public boolean accepted() {
return((($_ngcc_current_state == 1) || ($_ngcc_current_state == 0)));
}
private XPathImpl makeResult() {
return new XPathImpl($runtime.document,ann,$runtime.copyLocator(),fa,
$runtime.createXmlString(xpath));
}
}

View File

@@ -0,0 +1,187 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.scd;
import com.sun.xml.internal.xsom.XSAnnotation;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSComponent;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSNotation;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSSchema;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.XSXPath;
import com.sun.xml.internal.xsom.visitor.XSFunction;
import java.util.Iterator;
/**
* Partial default implementation of {@link Axis}.
*
* <p>
* {@link XSParticle}s are skipped in SCD, so this class compensates that.
* For example, when we are considering a path from {@link XSComplexType},
* we need to also consider a path from its content type particle (if any.)
*
* @author Kohsuke Kawaguchi
*/
abstract class AbstractAxisImpl<T extends XSComponent> implements Axis<T>, XSFunction<Iterator<T>> {
/**
* Creates a singleton list.
*/
protected final Iterator<T> singleton(T t) {
return Iterators.singleton(t);
}
protected final Iterator<T> union(T... items) {
return new Iterators.Array<T>(items);
}
protected final Iterator<T> union(Iterator<? extends T> first, Iterator<? extends T> second) {
return new Iterators.Union<T>(first,second);
}
public Iterator<T> iterator(XSComponent contextNode) {
return contextNode.apply(this);
}
/**
* Gets the prefix of the axis, like "foo::".
*/
public String getName() {
return toString();
}
/**
* Default implementation that simply delegate sto {@link #iterator(XSComponent)}
*/
public Iterator<T> iterator(Iterator<? extends XSComponent> contextNodes) {
return new Iterators.Map<T,XSComponent>(contextNodes) {
protected Iterator<? extends T> apply(XSComponent u) {
return iterator(u);
}
};
}
public boolean isModelGroup() {
return false;
}
public Iterator<T> annotation(XSAnnotation ann) {
return empty();
}
public Iterator<T> attGroupDecl(XSAttGroupDecl decl) {
return empty();
}
public Iterator<T> attributeDecl(XSAttributeDecl decl) {
return empty();
}
public Iterator<T> attributeUse(XSAttributeUse use) {
return empty();
}
public Iterator<T> complexType(XSComplexType type) {
// compensate particle
XSParticle p = type.getContentType().asParticle();
if(p!=null)
return particle(p);
else
return empty();
}
public Iterator<T> schema(XSSchema schema) {
return empty();
}
public Iterator<T> facet(XSFacet facet) {
return empty();
}
public Iterator<T> notation(XSNotation notation) {
return empty();
}
public Iterator<T> identityConstraint(XSIdentityConstraint decl) {
return empty();
}
public Iterator<T> xpath(XSXPath xpath) {
return empty();
}
public Iterator<T> simpleType(XSSimpleType simpleType) {
return empty();
}
public Iterator<T> particle(XSParticle particle) {
return empty();
}
public Iterator<T> empty(XSContentType empty) {
return empty();
}
public Iterator<T> wildcard(XSWildcard wc) {
return empty();
}
public Iterator<T> modelGroupDecl(XSModelGroupDecl decl) {
return empty();
}
public Iterator<T> modelGroup(XSModelGroup group) {
// compensate for particles that are ignored in SCD
return new Iterators.Map<T,XSParticle>(group.iterator()) {
protected Iterator<? extends T> apply(XSParticle p) {
return particle(p);
}
};
}
public Iterator<T> elementDecl(XSElementDecl decl) {
return empty();
}
/**
* Returns an empty list.
*/
protected final Iterator<T> empty() {
return Iterators.empty();
}
}

View File

@@ -0,0 +1,579 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.scd;
import com.sun.xml.internal.xsom.XSAttContainer;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSComponent;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSListSimpleType;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroup.Compositor;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSNotation;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSRestrictionSimpleType;
import com.sun.xml.internal.xsom.XSSchema;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.XSUnionSimpleType;
import com.sun.xml.internal.xsom.XSWildcard;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* Axis of traversal.
*
* @param <T>
* The kind of components that this axis may return.
*
* @author Kohsuke Kawaguchi
*/
public interface Axis<T extends XSComponent> {
Iterator<T> iterator(XSComponent contextNode);
Iterator<T> iterator(Iterator<? extends XSComponent> contextNodes);
/**
* Returns true if this is one of the model group axis.
*/
boolean isModelGroup();
/**
* Pseudo-axis that selects all the {@link XSSchema}s in the current set.
* Used to implement the absolute path expression
*/
public static final Axis<XSSchema> ROOT = new Axis<XSSchema>() {
public Iterator<XSSchema> iterator(XSComponent contextNode) {
return contextNode.getRoot().iterateSchema();
}
public Iterator<XSSchema> iterator(Iterator<? extends XSComponent> contextNodes) {
if(!contextNodes.hasNext())
return Iterators.empty();
else
// this assumes that all current nodes belong to the same owner.
return iterator(contextNodes.next());
}
public boolean isModelGroup() {
return false;
}
public String toString() {
return "root::";
}
};
/**
* Pseudo-axis that visits all skipped intermediate steps.
* Those are:
* <ol>
* <li>complex type reachable from element
* <li>model groups
* <li>combination of above.
* </ol>
*/
public static final Axis<XSComponent> INTERMEDIATE_SKIP = new AbstractAxisImpl<XSComponent>() {
public Iterator<XSComponent> elementDecl(XSElementDecl decl) {
XSComplexType ct = decl.getType().asComplexType();
if(ct==null)
return empty();
else {
// also pick up model groups inside this complex type
return new Iterators.Union<XSComponent>(singleton(ct),complexType(ct));
}
}
public Iterator<XSComponent> modelGroupDecl(XSModelGroupDecl decl) {
return descendants(decl.getModelGroup());
}
public Iterator<XSComponent> particle(XSParticle particle) {
return descendants(particle.getTerm().asModelGroup());
}
/**
* Iterate all descendant model groups of the given model group, including itself.
*/
private Iterator<XSComponent> descendants(XSModelGroup mg) {
// TODO: write a tree iterator
// for now, we do it eagerly because I'm lazy
List<XSComponent> r = new ArrayList<XSComponent>();
visit(mg,r);
return r.iterator();
}
private void visit(XSModelGroup mg, List<XSComponent> r) {
// since model groups never form a cycle, no cycle check is needed
r.add(mg);
for (XSParticle p : mg) {
XSModelGroup child = p.getTerm().asModelGroup();
if(child!=null)
visit(child,r);
}
}
public String toString() {
return "(intermediateSkip)";
}
};
/**
* All descendants reachable via default axes. Used to implement the "//" semantics.
*
* So far the default axes together are guaranteed not to cause any cycle, so
* no cycle check is needed (if it's needed, the life would be much harder!)
*/
public static final Axis<XSComponent> DESCENDANTS = new Axis<XSComponent>() {
public Iterator<XSComponent> iterator(XSComponent contextNode) {
return new Visitor().iterator(contextNode);
}
public Iterator<XSComponent> iterator(Iterator<? extends XSComponent> contextNodes) {
return new Visitor().iterator(contextNodes);
}
public boolean isModelGroup() {
return false;
}
/**
* Stateful visitor that remembers what's already traversed, to reduce the search space.
*/
final class Visitor extends AbstractAxisImpl<XSComponent> {
private final Set<XSComponent> visited = new HashSet<XSComponent>();
/**
* Recursively apply the {@link Axis#DESCENDANTS} axis.
*/
final class Recursion extends Iterators.Map<XSComponent,XSComponent> {
public Recursion(Iterator<? extends XSComponent> core) {
super(core);
}
protected Iterator<XSComponent> apply(XSComponent u) {
return DESCENDANTS.iterator(u);
}
}
public Iterator<XSComponent> schema(XSSchema schema) {
if(visited.add(schema))
return ret( schema, new Recursion(schema.iterateElementDecls()));
else
return empty();
}
public Iterator<XSComponent> elementDecl(XSElementDecl decl) {
if(visited.add(decl))
return ret(decl, iterator(decl.getType()) );
else
return empty();
}
public Iterator<XSComponent> simpleType(XSSimpleType type) {
if(visited.add(type))
return ret(type, FACET.iterator(type));
else
return empty();
}
public Iterator<XSComponent> complexType(XSComplexType type) {
if(visited.add(type))
return ret(type, iterator(type.getContentType()));
else
return empty();
}
public Iterator<XSComponent> particle(XSParticle particle) {
if(visited.add(particle))
return ret(particle, iterator(particle.getTerm()));
else
return empty();
}
public Iterator<XSComponent> modelGroupDecl(XSModelGroupDecl decl) {
if(visited.add(decl))
return ret(decl, iterator(decl.getModelGroup()));
else
return empty();
}
public Iterator<XSComponent> modelGroup(XSModelGroup group) {
if(visited.add(group))
return ret(group, new Recursion(group.iterator()));
else
return empty();
}
public Iterator<XSComponent> attGroupDecl(XSAttGroupDecl decl) {
if(visited.add(decl))
return ret(decl, new Recursion(decl.iterateAttributeUses()));
else
return empty();
}
public Iterator<XSComponent> attributeUse(XSAttributeUse use) {
if(visited.add(use))
return ret(use, iterator(use.getDecl()));
else
return empty();
}
public Iterator<XSComponent> attributeDecl(XSAttributeDecl decl) {
if(visited.add(decl))
return ret(decl, iterator(decl.getType()));
else
return empty();
}
private Iterator<XSComponent> ret( XSComponent one, Iterator<? extends XSComponent> rest ) {
return union(singleton(one),rest);
}
}
public String toString() {
return "/";
}
};
public static final Axis<XSSchema> X_SCHEMA = new Axis<XSSchema>() {
public Iterator<XSSchema> iterator(XSComponent contextNode) {
return Iterators.singleton(contextNode.getOwnerSchema());
}
public Iterator<XSSchema> iterator(Iterator<? extends XSComponent> contextNodes) {
return new Iterators.Adapter<XSSchema,XSComponent>(contextNodes) {
protected XSSchema filter(XSComponent u) {
return u.getOwnerSchema();
}
};
}
public boolean isModelGroup() {
return false;
}
public String toString() {
return "x-schema::";
}
};
public static final Axis<XSElementDecl> SUBSTITUTION_GROUP = new AbstractAxisImpl<XSElementDecl>() {
public Iterator<XSElementDecl> elementDecl(XSElementDecl decl) {
return singleton(decl.getSubstAffiliation());
}
public String toString() {
return "substitutionGroup::";
}
};
public static final Axis<XSAttributeDecl> ATTRIBUTE = new AbstractAxisImpl<XSAttributeDecl>() {
public Iterator<XSAttributeDecl> complexType(XSComplexType type) {
return attributeHolder(type);
}
public Iterator<XSAttributeDecl> attGroupDecl(XSAttGroupDecl decl) {
return attributeHolder(decl);
}
private Iterator<XSAttributeDecl> attributeHolder(final XSAttContainer atts) {
// TODO: check spec. is this correct?
return new Iterators.Adapter<XSAttributeDecl,XSAttributeUse>(atts.iterateAttributeUses()) {
protected XSAttributeDecl filter(XSAttributeUse u) {
return u.getDecl();
}
};
}
public Iterator<XSAttributeDecl> schema(XSSchema schema) {
return schema.iterateAttributeDecls();
}
public String toString() {
return "@";
}
};
public static final Axis<XSElementDecl> ELEMENT = new AbstractAxisImpl<XSElementDecl>() {
public Iterator<XSElementDecl> particle(XSParticle particle) {
return singleton(particle.getTerm().asElementDecl());
}
public Iterator<XSElementDecl> schema(XSSchema schema) {
return schema.iterateElementDecls();
}
public Iterator<XSElementDecl> modelGroupDecl(XSModelGroupDecl decl) {
return modelGroup(decl.getModelGroup());
}
//public Iterator<XSElementDecl> modelGroup(XSModelGroup group) {
// return new Iterators.Map<XSElementDecl,XSParticle>(group.iterator()) {
// protected Iterator<XSElementDecl> apply(XSParticle p) {
// return particle(p);
// }
// };
//}
@Override
public String getName() {
return "";
}
public String toString() {
return "element::";
}
};
public static final Axis<XSType> TYPE_DEFINITION = new AbstractAxisImpl<XSType>() {
public Iterator<XSType> schema(XSSchema schema) {
return schema.iterateTypes();
}
public Iterator<XSType> attributeDecl(XSAttributeDecl decl) {
return singleton(decl.getType());
}
public Iterator<XSType> elementDecl(XSElementDecl decl) {
return singleton(decl.getType());
}
public String toString() {
return "~";
}
};
public static final Axis<XSType> BASETYPE = new AbstractAxisImpl<XSType>() {
public Iterator<XSType> simpleType(XSSimpleType type) {
return singleton(type.getBaseType());
}
public Iterator<XSType> complexType(XSComplexType type) {
return singleton(type.getBaseType());
}
public String toString() {
return "baseType::";
}
};
public static final Axis<XSSimpleType> PRIMITIVE_TYPE = new AbstractAxisImpl<XSSimpleType>() {
public Iterator<XSSimpleType> simpleType(XSSimpleType type) {
return singleton(type.getPrimitiveType());
}
public String toString() {
return "primitiveType::";
}
};
public static final Axis<XSSimpleType> ITEM_TYPE = new AbstractAxisImpl<XSSimpleType>() {
public Iterator<XSSimpleType> simpleType(XSSimpleType type) {
XSListSimpleType baseList = type.getBaseListType();
if(baseList==null) return empty();
return singleton(baseList.getItemType());
}
public String toString() {
return "itemType::";
}
};
public static final Axis<XSSimpleType> MEMBER_TYPE = new AbstractAxisImpl<XSSimpleType>() {
public Iterator<XSSimpleType> simpleType(XSSimpleType type) {
XSUnionSimpleType baseUnion = type.getBaseUnionType();
if(baseUnion ==null) return empty();
return baseUnion.iterator();
}
public String toString() {
return "memberType::";
}
};
public static final Axis<XSComponent> SCOPE = new AbstractAxisImpl<XSComponent>() {
public Iterator<XSComponent> complexType(XSComplexType type) {
return singleton(type.getScope());
}
// TODO: attribute declaration has a scope, too.
// TODO: element declaration has a scope
public String toString() {
return "scope::";
}
};
public static final Axis<XSAttGroupDecl> ATTRIBUTE_GROUP = new AbstractAxisImpl<XSAttGroupDecl>() {
public Iterator<XSAttGroupDecl> schema(XSSchema schema) {
return schema.iterateAttGroupDecls();
}
public String toString() {
return "attributeGroup::";
}
};
public static final Axis<XSModelGroupDecl> MODEL_GROUP_DECL = new AbstractAxisImpl<XSModelGroupDecl>() {
public Iterator<XSModelGroupDecl> schema(XSSchema schema) {
return schema.iterateModelGroupDecls();
}
public Iterator<XSModelGroupDecl> particle(XSParticle particle) {
return singleton(particle.getTerm().asModelGroupDecl());
}
public String toString() {
return "group::";
}
};
public static final Axis<XSIdentityConstraint> IDENTITY_CONSTRAINT = new AbstractAxisImpl<XSIdentityConstraint>() {
public Iterator<XSIdentityConstraint> elementDecl(XSElementDecl decl) {
return decl.getIdentityConstraints().iterator();
}
public Iterator<XSIdentityConstraint> schema(XSSchema schema) {
// TODO: iterate all elements in this schema (local or global!) and its identity constraints
return super.schema(schema);
}
public String toString() {
return "identityConstraint::";
}
};
public static final Axis<XSIdentityConstraint> REFERENCED_KEY = new AbstractAxisImpl<XSIdentityConstraint>() {
public Iterator<XSIdentityConstraint> identityConstraint(XSIdentityConstraint decl) {
return singleton(decl.getReferencedKey());
}
public String toString() {
return "key::";
}
};
public static final Axis<XSNotation> NOTATION = new AbstractAxisImpl<XSNotation>() {
public Iterator<XSNotation> schema(XSSchema schema) {
return schema.iterateNotations();
}
public String toString() {
return "notation::";
}
};
public static final Axis<XSWildcard> WILDCARD = new AbstractAxisImpl<XSWildcard>() {
public Iterator<XSWildcard> particle(XSParticle particle) {
return singleton(particle.getTerm().asWildcard());
}
public String toString() {
return "any::";
}
};
public static final Axis<XSWildcard> ATTRIBUTE_WILDCARD = new AbstractAxisImpl<XSWildcard>() {
public Iterator<XSWildcard> complexType(XSComplexType type) {
return singleton(type.getAttributeWildcard());
}
public Iterator<XSWildcard> attGroupDecl(XSAttGroupDecl decl) {
return singleton(decl.getAttributeWildcard());
}
public String toString() {
return "anyAttribute::";
}
};
public static final Axis<XSFacet> FACET = new AbstractAxisImpl<XSFacet>() {
public Iterator<XSFacet> simpleType(XSSimpleType type) {
// TODO: it's not clear if "facets" mean all inherited facets or just declared facets
XSRestrictionSimpleType r = type.asRestriction();
if(r!=null)
return r.iterateDeclaredFacets();
else
return empty();
}
public String toString() {
return "facet::";
}
};
public static final Axis<XSModelGroup> MODELGROUP_ALL = new ModelGroupAxis(Compositor.ALL);
public static final Axis<XSModelGroup> MODELGROUP_CHOICE = new ModelGroupAxis(Compositor.CHOICE);
public static final Axis<XSModelGroup> MODELGROUP_SEQUENCE = new ModelGroupAxis(Compositor.SEQUENCE);
public static final Axis<XSModelGroup> MODELGROUP_ANY = new ModelGroupAxis(null);
static final class ModelGroupAxis extends AbstractAxisImpl<XSModelGroup> {
private final XSModelGroup.Compositor compositor;
ModelGroupAxis(Compositor compositor) {
this.compositor = compositor;
}
@Override
public boolean isModelGroup() {
return true;
}
public Iterator<XSModelGroup> particle(XSParticle particle) {
return filter(particle.getTerm().asModelGroup());
}
public Iterator<XSModelGroup> modelGroupDecl(XSModelGroupDecl decl) {
return filter(decl.getModelGroup());
}
private Iterator<XSModelGroup> filter(XSModelGroup mg) {
if(mg==null)
return empty();
if(mg.getCompositor() == compositor || compositor == null)
return singleton(mg);
else
return empty();
}
public String toString() {
if(compositor==null)
return "model::*";
else
return "model::"+compositor;
}
}
}

View File

@@ -0,0 +1,215 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.scd;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
/**
* Various convenient {@link Iterator} implementations.
* @author Kohsuke Kawaguchi
*/
public class Iterators {
static abstract class ReadOnly<T> implements Iterator<T> {
public final void remove() {
throw new UnsupportedOperationException();
}
}
// we need to run on JDK 1.4
private static final Iterator EMPTY = Collections.EMPTY_LIST.iterator();
public static <T> Iterator<T> empty() {
return EMPTY;
}
public static <T> Iterator<T> singleton(T value) {
return new Singleton<T>(value);
}
/**
* {@link Iterator} that returns a single (or no) value.
*/
static final class Singleton<T> extends ReadOnly<T> {
private T next;
Singleton(T next) {
this.next = next;
}
public boolean hasNext() {
return next!=null;
}
public T next() {
T r = next;
next = null;
return r;
}
}
/**
* {@link Iterator} that wraps another {@link Iterator} and changes its type.
*/
public static abstract class Adapter<T,U> extends ReadOnly<T> {
private final Iterator<? extends U> core;
public Adapter(Iterator<? extends U> core) {
this.core = core;
}
public boolean hasNext() {
return core.hasNext();
}
public T next() {
return filter(core.next());
}
protected abstract T filter(U u);
}
/**
* For each U, apply U->Iterator&lt;T> function and then iterate all
* the resulting T.
*/
public static abstract class Map<T,U> extends ReadOnly<T> {
private final Iterator<? extends U> core;
private Iterator<? extends T> current;
protected Map(Iterator<? extends U> core) {
this.core = core;
}
public boolean hasNext() {
while(current==null || !current.hasNext()) {
if(!core.hasNext())
return false; // nothing more to enumerate
current = apply(core.next());
}
return true;
}
public T next() {
return current.next();
}
protected abstract Iterator<? extends T> apply(U u);
}
/**
* Filter out objects from another iterator.
*/
public static abstract class Filter<T> extends ReadOnly<T> {
private final Iterator<? extends T> core;
private T next;
protected Filter(Iterator<? extends T> core) {
this.core = core;
}
/**
* Return true to retain the value.
*/
protected abstract boolean matches(T value);
public boolean hasNext() {
while(core.hasNext() && next==null) {
next = core.next();
if(!matches(next))
next = null;
}
return next!=null;
}
public T next() {
if(next==null) throw new NoSuchElementException();
T r = next;
next = null;
return r;
}
}
/**
* Only return unique items.
*/
static final class Unique<T> extends Filter<T> {
private Set<T> values = new HashSet<T>();
public Unique(Iterator<? extends T> core) {
super(core);
}
protected boolean matches(T value) {
return values.add(value);
}
}
/**
* Union of two iterators.
*/
public static final class Union<T> extends ReadOnly<T> {
private final Iterator<? extends T> first,second;
public Union(Iterator<? extends T> first, Iterator<? extends T> second) {
this.first = first;
this.second = second;
}
public boolean hasNext() {
return first.hasNext() || second.hasNext();
}
public T next() {
if(first.hasNext()) return first.next();
else return second.next();
}
}
/**
* Array iterator.
*/
public static final class Array<T> extends ReadOnly<T> {
private final T[] items;
private int index=0;
public Array(T[] items) {
this.items = items;
}
public boolean hasNext() {
return index<items.length;
}
public T next() {
return items[index++];
}
}
}

View File

@@ -0,0 +1,219 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
package com.sun.xml.internal.xsom.impl.scd;
import java.util.List;
/**
* This exception is thrown when parse errors are encountered.
* You can explicitly create objects of this exception type by
* calling the method generateParseException in the generated
* parser.
*
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
public class ParseException extends Exception {
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
* a new object of this type with the fields "currentToken",
* "expectedTokenSequences", and "tokenImage" set. The boolean
* flag "specialConstructor" is also set to true to indicate that
* this constructor was used to create this object.
* This constructor calls its super class with the empty string
* to force the "toString" method of parent class "Throwable" to
* print the error message in the form:
* ParseException: <result of getMessage>
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
List<String> tokenImageVal
)
{
super("");
specialConstructor = true;
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
}
/**
* The following constructors are for use by you for whatever
* purpose you can think of. Constructing the exception in this
* manner makes the exception behave in the normal way - i.e., as
* documented in the class "Throwable". The fields "errorToken",
* "expectedTokenSequences", and "tokenImage" do not contain
* relevant information. The JavaCC generated code does not use
* these constructors.
*/
public ParseException() {
super();
specialConstructor = false;
}
public ParseException(String message) {
super(message);
specialConstructor = false;
}
/**
* This variable determines which constructor was used to create
* this object and thereby affects the semantics of the
* "getMessage" method (see below).
*/
protected boolean specialConstructor;
/**
* This is the last token that has been consumed successfully. If
* this object has been created due to a parse error, the token
* followng this token will (therefore) be the first error token.
*/
public Token currentToken;
/**
* Each entry in this array is an array of integers. Each array
* of integers represents a sequence of tokens (by their ordinal
* values) that is expected at this point of the parse.
*/
public int[][] expectedTokenSequences;
/**
* This is a reference to the "tokenImage" array of the generated
* parser within which the parse error occurred. This array is
* defined in the generated ...Constants interface.
*/
public List<String> tokenImage;
/**
* This method has the standard behavior when this object has been
* created using the standard constructors. Otherwise, it uses
* "currentToken" and "expectedTokenSequences" to generate a parse
* error message and returns it. If this object has been created
* due to a parse error, and you do not catch it (it gets thrown
* from the parser), then this method is called during the printing
* of the final stack trace, and hence the correct error message
* gets displayed.
*/
public String getMessage() {
if (!specialConstructor) {
return super.getMessage();
}
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected.append(tokenImage.get(expectedTokenSequences[i][j])).append(" ");
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage.get(0);
break;
}
retval += add_escapes(tok.image);
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
* when these raw version cannot be used as part of an ASCII
* string literal.
*/
protected String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.scd;
import com.sun.xml.internal.xsom.SCD;
import com.sun.xml.internal.xsom.XSComponent;
import java.util.Iterator;
/**
* Schema component designator.
*
* @author Kohsuke Kawaguchi
*/
public final class SCDImpl extends SCD {
/**
* SCD is fundamentally a list of steps.
*/
private final Step[] steps;
/**
* The original textual SCD representation.
*/
private final String text;
public SCDImpl(String text, Step[] steps) {
this.text = text;
this.steps = steps;
}
public Iterator<XSComponent> select(Iterator<? extends XSComponent> contextNode) {
Iterator<XSComponent> nodeSet = (Iterator)contextNode;
int len = steps.length;
for( int i=0; i<len; i++ ) {
if(i!=0 && i!=len-1 && !steps[i-1].axis.isModelGroup() && steps[i].axis.isModelGroup()) {
// expand the current nodeset by adding abbreviatable complex type and model groups.
// note that such expansion is not allowed to occure in in between model group axes.
// TODO: this step is not needed if the next step is known not to react to
// complex type nor model groups, such as, say Axis.FACET
nodeSet = new Iterators.Unique<XSComponent>(
new Iterators.Map<XSComponent,XSComponent>(nodeSet) {
protected Iterator<XSComponent> apply(XSComponent u) {
return new Iterators.Union<XSComponent>(
Iterators.singleton(u),
Axis.INTERMEDIATE_SKIP.iterator(u) );
}
}
);
}
nodeSet = steps[i].evaluate(nodeSet);
}
return nodeSet;
}
public String toString() {
return text;
}
}

View File

@@ -0,0 +1,562 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Generated By:JavaCC: Do not edit this line. SCDParser.java */
package com.sun.xml.internal.xsom.impl.scd;
import java.util.*;
import java.io.*;
import com.sun.xml.internal.xsom.impl.UName;
import javax.xml.namespace.*;
public class SCDParser implements SCDParserConstants {
private NamespaceContext nsc;
public SCDParser(String text,NamespaceContext nsc) {
this(new StringReader(text));
this.nsc = nsc;
}
private String trim(String s) {
return s.substring(1,s.length()-1);
}
private String resolvePrefix(String prefix) throws ParseException {
try {
String r=nsc.getNamespaceURI(prefix);
// grrr!!
if(prefix.equals(""))
return r;
if(!r.equals(""))
return r;
} catch( IllegalArgumentException e ) {
; // report an error
}
throw new ParseException("Unbound prefix: "+prefix);
}
// "[^:]+"
final public UName QName() throws ParseException {
Token p,l=null;
p = jj_consume_token(NCNAME);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 15:
jj_consume_token(15);
l = jj_consume_token(NCNAME);
break;
default:
jj_la1[0] = jj_gen;
;
}
if(l==null)
{if (true) return new UName(resolvePrefix(""),p.image);}
else
{if (true) return new UName(resolvePrefix(p.image),l.image);}
throw new Error("Missing return statement in function");
}
final public String Prefix() throws ParseException {
Token p;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NCNAME:
p = jj_consume_token(NCNAME);
{if (true) return resolvePrefix(p.image);}
break;
default:
jj_la1[1] = jj_gen;
{if (true) return resolvePrefix("");}
}
throw new Error("Missing return statement in function");
}
final public List RelativeSchemaComponentPath() throws ParseException {
List steps = new ArrayList();
Step s;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 16:
case 17:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 16:
jj_consume_token(16);
steps.add(new Step.Any(Axis.ROOT));
break;
case 17:
jj_consume_token(17);
steps.add(new Step.Any(Axis.DESCENDANTS));
break;
default:
jj_la1[2] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
jj_la1[3] = jj_gen;
;
}
s = Step();
steps.add(s);
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 16:
case 17:
;
break;
default:
jj_la1[4] = jj_gen;
break label_1;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 16:
jj_consume_token(16);
break;
case 17:
jj_consume_token(17);
steps.add(new Step.Any(Axis.DESCENDANTS));
break;
default:
jj_la1[5] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
s = Step();
steps.add(s);
}
{if (true) return steps;}
throw new Error("Missing return statement in function");
}
final public Step Step() throws ParseException {
Step s; String p; Token n;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 18:
case 19:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 18:
jj_consume_token(18);
break;
case 19:
jj_consume_token(19);
break;
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
s = NameOrWildcard(Axis.ATTRIBUTE);
break;
case NCNAME:
case 20:
case 45:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 20:
jj_consume_token(20);
break;
default:
jj_la1[7] = jj_gen;
;
}
s = NameOrWildcard(Axis.ELEMENT);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
Predicate(s);
break;
default:
jj_la1[8] = jj_gen;
;
}
break;
case 21:
jj_consume_token(21);
s = NameOrWildcard(Axis.SUBSTITUTION_GROUP);
break;
case 22:
case 23:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 22:
jj_consume_token(22);
break;
case 23:
jj_consume_token(23);
break;
default:
jj_la1[9] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
s = NameOrWildcardOrAnonymous(Axis.TYPE_DEFINITION);
break;
case 24:
jj_consume_token(24);
s = NameOrWildcard(Axis.BASETYPE);
break;
case 25:
jj_consume_token(25);
s = NameOrWildcard(Axis.PRIMITIVE_TYPE);
break;
case 26:
jj_consume_token(26);
s = NameOrWildcardOrAnonymous(Axis.ITEM_TYPE);
break;
case 27:
jj_consume_token(27);
s = NameOrWildcardOrAnonymous(Axis.MEMBER_TYPE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
Predicate(s);
break;
default:
jj_la1[10] = jj_gen;
;
}
break;
case 28:
jj_consume_token(28);
s = NameOrWildcardOrAnonymous(Axis.SCOPE);
break;
case 29:
jj_consume_token(29);
s = NameOrWildcard(Axis.ATTRIBUTE_GROUP);
break;
case 30:
jj_consume_token(30);
s = NameOrWildcard(Axis.MODEL_GROUP_DECL);
break;
case 31:
jj_consume_token(31);
s = NameOrWildcard(Axis.IDENTITY_CONSTRAINT);
break;
case 32:
jj_consume_token(32);
s = NameOrWildcard(Axis.REFERENCED_KEY);
break;
case 33:
jj_consume_token(33);
s = NameOrWildcard(Axis.NOTATION);
break;
case 34:
jj_consume_token(34);
s=new Step.Any(Axis.MODELGROUP_SEQUENCE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
Predicate(s);
break;
default:
jj_la1[11] = jj_gen;
;
}
break;
case 35:
jj_consume_token(35);
s=new Step.Any(Axis.MODELGROUP_CHOICE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
Predicate(s);
break;
default:
jj_la1[12] = jj_gen;
;
}
break;
case 36:
jj_consume_token(36);
s=new Step.Any(Axis.MODELGROUP_ALL);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
Predicate(s);
break;
default:
jj_la1[13] = jj_gen;
;
}
break;
case 37:
jj_consume_token(37);
s=new Step.Any(Axis.MODELGROUP_ANY);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
Predicate(s);
break;
default:
jj_la1[14] = jj_gen;
;
}
break;
case 38:
jj_consume_token(38);
s=new Step.Any(Axis.WILDCARD);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NUMBER:
Predicate(s);
break;
default:
jj_la1[15] = jj_gen;
;
}
break;
case 39:
jj_consume_token(39);
s=new Step.Any(Axis.ATTRIBUTE_WILDCARD);
break;
case 40:
jj_consume_token(40);
s=new Step.Any(Axis.FACET);
break;
case 41:
jj_consume_token(41);
n = jj_consume_token(FACETNAME);
s=new Step.Facet(Axis.FACET,n.image);
break;
case 42:
jj_consume_token(42);
s=new Step.Any(Axis.DESCENDANTS);
break;
case 43:
jj_consume_token(43);
p = Prefix();
s=new Step.Schema(Axis.X_SCHEMA,p);
break;
case 44:
jj_consume_token(44);
s=new Step.Any(Axis.X_SCHEMA);
break;
default:
jj_la1[16] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return s;}
throw new Error("Missing return statement in function");
}
final public Step NameOrWildcard(Axis a) throws ParseException {
UName un;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NCNAME:
un = QName();
{if (true) return new Step.Named(a,un);}
break;
case 45:
jj_consume_token(45);
{if (true) return new Step.Any(a);}
break;
default:
jj_la1[17] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
final public Step NameOrWildcardOrAnonymous(Axis a) throws ParseException {
UName un;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case NCNAME:
un = QName();
{if (true) return new Step.Named(a,un);}
break;
case 45:
jj_consume_token(45);
{if (true) return new Step.Any(a);}
break;
case 46:
jj_consume_token(46);
{if (true) return new Step.AnonymousType(a);}
break;
default:
jj_la1[18] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
throw new Error("Missing return statement in function");
}
final public int Predicate(Step s) throws ParseException {
Token t;
t = jj_consume_token(NUMBER);
{if (true) return s.predicate=Integer.parseInt(trim(t.image));}
throw new Error("Missing return statement in function");
}
public SCDParserTokenManager token_source;
SimpleCharStream jj_input_stream;
public Token token, jj_nt;
private int jj_ntk;
private int jj_gen;
final private int[] jj_la1 = new int[19];
static private int[] jj_la1_0;
static private int[] jj_la1_1;
static {
jj_la1_0();
jj_la1_1();
}
private static void jj_la1_0() {
jj_la1_0 = new int[] {0x8000,0x1000,0x30000,0x30000,0x30000,0x30000,0xc0000,0x100000,0x2000,0xc00000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0xfffc1000,0x1000,0x1000,};
}
private static void jj_la1_1() {
jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3fff,0x2000,0x6000,};
}
public SCDParser(java.io.InputStream stream) {
this(stream, null);
}
public SCDParser(java.io.InputStream stream, String encoding) {
try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source = new SCDParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
public void ReInit(java.io.InputStream stream) {
ReInit(stream, null);
}
public void ReInit(java.io.InputStream stream, String encoding) {
try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
public SCDParser(java.io.Reader stream) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
token_source = new SCDParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
public SCDParser(SCDParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
public void ReInit(SCDParserTokenManager tm) {
token_source = tm;
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 19; i++) jj_la1[i] = -1;
}
final private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
return token;
}
token = oldToken;
jj_kind = kind;
throw generateParseException();
}
final public Token getNextToken() {
if (token.next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
jj_gen++;
return token;
}
final public Token getToken(int index) {
Token t = token;
for (int i = 0; i < index; i++) {
if (t.next != null) t = t.next;
else t = t.next = token_source.getNextToken();
}
return t;
}
final private int jj_ntk() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
return (jj_ntk = jj_nt.kind);
}
private java.util.Vector jj_expentries = new java.util.Vector();
private int[] jj_expentry;
private int jj_kind = -1;
public ParseException generateParseException() {
jj_expentries.removeAllElements();
boolean[] la1tokens = new boolean[47];
for (int i = 0; i < 47; i++) {
la1tokens[i] = false;
}
if (jj_kind >= 0) {
la1tokens[jj_kind] = true;
jj_kind = -1;
}
for (int i = 0; i < 19; i++) {
if (jj_la1[i] == jj_gen) {
for (int j = 0; j < 32; j++) {
if ((jj_la1_0[i] & (1<<j)) != 0) {
la1tokens[j] = true;
}
if ((jj_la1_1[i] & (1<<j)) != 0) {
la1tokens[32+j] = true;
}
}
}
}
for (int i = 0; i < 47; i++) {
if (la1tokens[i]) {
jj_expentry = new int[1];
jj_expentry[0] = i;
jj_expentries.addElement(jj_expentry);
}
}
int[][] exptokseq = new int[jj_expentries.size()][];
for (int i = 0; i < jj_expentries.size(); i++) {
exptokseq[i] = (int[])jj_expentries.elementAt(i);
}
return new ParseException(token, exptokseq, tokenImage);
}
final public void enable_tracing() {
}
final public void disable_tracing() {
}
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Generated By:JavaCC: Do not edit this line. SCDParserConstants.java */
package com.sun.xml.internal.xsom.impl.scd;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public interface SCDParserConstants {
int EOF = 0;
int Letter = 6;
int BaseChar = 7;
int Ideographic = 8;
int CombiningChar = 9;
int UnicodeDigit = 10;
int Extender = 11;
int NCNAME = 12;
int NUMBER = 13;
int FACETNAME = 14;
int DEFAULT = 0;
static final List<String> tokenImage = Collections.unmodifiableList(Arrays.asList(
new String[] {
"<EOF>",
"\" \"",
"\"\\t\"",
"\"\\n\"",
"\"\\r\"",
"\"\\f\"",
"<Letter>",
"<BaseChar>",
"<Ideographic>",
"<CombiningChar>",
"<UnicodeDigit>",
"<Extender>",
"<NCNAME>",
"<NUMBER>",
"<FACETNAME>",
"\":\"",
"\"/\"",
"\"//\"",
"\"attribute::\"",
"\"@\"",
"\"element::\"",
"\"substitutionGroup::\"",
"\"type::\"",
"\"~\"",
"\"baseType::\"",
"\"primitiveType::\"",
"\"itemType::\"",
"\"memberType::\"",
"\"scope::\"",
"\"attributeGroup::\"",
"\"group::\"",
"\"identityContraint::\"",
"\"key::\"",
"\"notation::\"",
"\"model::sequence\"",
"\"model::choice\"",
"\"model::all\"",
"\"model::*\"",
"\"any::*\"",
"\"anyAttribute::*\"",
"\"facet::*\"",
"\"facet::\"",
"\"component::*\"",
"\"x-schema::\"",
"\"x-schema::*\"",
"\"*\"",
"\"0\"",
}));
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,464 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */
package com.sun.xml.internal.xsom.impl.scd;
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain only ASCII characters (without unicode processing).
*/
public class SimpleCharStream
{
public static final boolean staticFlag = false;
int bufsize;
int available;
int tokenBegin;
public int bufpos = -1;
protected int bufline[];
protected int bufcolumn[];
protected int column = 0;
protected int line = 1;
protected boolean prevCharIsCR = false;
protected boolean prevCharIsLF = false;
protected java.io.Reader inputStream;
protected char[] buffer;
protected int maxNextCharInd = 0;
protected int inBuf = 0;
protected int tabSize = 8;
protected void setTabSize(int i) { tabSize = i; }
protected int getTabSize(int i) { return tabSize; }
protected void ExpandBuff(boolean wrapAround)
{
char[] newbuffer = new char[bufsize + 2048];
int newbufline[] = new int[bufsize + 2048];
int newbufcolumn[] = new int[bufsize + 2048];
try
{
if (wrapAround)
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
System.arraycopy(buffer, 0, newbuffer,
bufsize - tokenBegin, bufpos);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
bufcolumn = newbufcolumn;
maxNextCharInd = (bufpos += (bufsize - tokenBegin));
}
else
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
bufcolumn = newbufcolumn;
maxNextCharInd = (bufpos -= tokenBegin);
}
}
catch (Throwable t)
{
throw new Error(t.getMessage());
}
bufsize += 2048;
available = bufsize;
tokenBegin = 0;
}
protected void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
bufpos = maxNextCharInd = 0;
else
ExpandBuff(false);
}
else if (available > tokenBegin)
available = bufsize;
else if ((tokenBegin - available) < 2048)
ExpandBuff(true);
else
available = tokenBegin;
}
int i;
try {
if ((i = inputStream.read(buffer, maxNextCharInd,
available - maxNextCharInd)) == -1)
{
inputStream.close();
throw new java.io.IOException();
}
else
maxNextCharInd += i;
return;
}
catch(java.io.IOException e) {
--bufpos;
backup(0);
if (tokenBegin == -1)
tokenBegin = bufpos;
throw e;
}
}
public char BeginToken() throws java.io.IOException
{
tokenBegin = -1;
char c = readChar();
tokenBegin = bufpos;
return c;
}
protected void UpdateLineColumn(char c)
{
column++;
if (prevCharIsLF)
{
prevCharIsLF = false;
line += (column = 1);
}
else if (prevCharIsCR)
{
prevCharIsCR = false;
if (c == '\n')
{
prevCharIsLF = true;
}
else
line += (column = 1);
}
switch (c)
{
case '\r' :
prevCharIsCR = true;
break;
case '\n' :
prevCharIsLF = true;
break;
case '\t' :
column--;
column += (tabSize - (column % tabSize));
break;
default :
break;
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
public char readChar() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
if (++bufpos == bufsize)
bufpos = 0;
return buffer[bufpos];
}
if (++bufpos >= maxNextCharInd)
FillBuff();
char c = buffer[bufpos];
UpdateLineColumn(c);
return (c);
}
/**
* @deprecated
* @see #getEndColumn
*/
public int getColumn() {
return bufcolumn[bufpos];
}
/**
* @deprecated
* @see #getEndLine
*/
public int getLine() {
return bufline[bufpos];
}
public int getEndColumn() {
return bufcolumn[bufpos];
}
public int getEndLine() {
return bufline[bufpos];
}
public int getBeginColumn() {
return bufcolumn[tokenBegin];
}
public int getBeginLine() {
return bufline[tokenBegin];
}
public void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
public SimpleCharStream(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
}
public SimpleCharStream(java.io.Reader dstream, int startline,
int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
public SimpleCharStream(java.io.Reader dstream)
{
this(dstream, 1, 1, 4096);
}
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
if (buffer == null || buffersize != buffer.length)
{
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
}
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
bufpos = -1;
}
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.Reader dstream)
{
ReInit(dstream, 1, 1, 4096);
}
public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
{
this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
}
public SimpleCharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
}
public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
int startcolumn) throws java.io.UnsupportedEncodingException
{
this(dstream, encoding, startline, startcolumn, 4096);
}
public SimpleCharStream(java.io.InputStream dstream, int startline,
int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
{
this(dstream, encoding, 1, 1, 4096);
}
public SimpleCharStream(java.io.InputStream dstream)
{
this(dstream, 1, 1, 4096);
}
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
{
ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
}
public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
{
ReInit(dstream, encoding, 1, 1, 4096);
}
public void ReInit(java.io.InputStream dstream)
{
ReInit(dstream, 1, 1, 4096);
}
public void ReInit(java.io.InputStream dstream, String encoding, int startline,
int startcolumn) throws java.io.UnsupportedEncodingException
{
ReInit(dstream, encoding, startline, startcolumn, 4096);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
public String GetImage()
{
if (bufpos >= tokenBegin)
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
else
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
new String(buffer, 0, bufpos + 1);
}
public char[] GetSuffix(int len)
{
char[] ret = new char[len];
if ((bufpos + 1) >= len)
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
else
{
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
}
public void Done()
{
buffer = null;
bufline = null;
bufcolumn = null;
}
/**
* Method to adjust line and column numbers for the start of a token.
*/
public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
while (i < len &&
bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len)
{
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len)
{
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
bufline[j] = newLine++;
else
bufline[j] = newLine;
}
}
line = bufline[j];
column = bufcolumn[j];
}
}

View File

@@ -0,0 +1,187 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.scd;
import com.sun.xml.internal.xsom.XSComponent;
import com.sun.xml.internal.xsom.XSDeclaration;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.SCD;
import com.sun.xml.internal.xsom.XSSchema;
import com.sun.xml.internal.xsom.impl.UName;
import java.util.Iterator;
/**
* Building block of {@link SCD}.
*
* @author Kohsuke Kawaguchi
*/
public abstract class Step<T extends XSComponent> {
public final Axis<? extends T> axis;
/**
* 'Predicate' in SCD designates the index of the item. -1 if there's no predicate.
* Predicate starts from 1.
*
* <p>
* Because of the parsing order this parameter cannot be marked
* final, even though it's immutable once it's parsed.
*/
int predicate = -1;
protected Step(Axis<? extends T> axis) {
this.axis = axis;
}
/**
* Perform filtering (which is different depending on the kind of step.)
*/
protected abstract Iterator<? extends T> filter( Iterator<? extends T> base );
/**
* Evaluate this step against the current node set
* and returns matched nodes.
*/
public final Iterator<T> evaluate(Iterator<XSComponent> nodeSet) {
// list up the whole thing
Iterator<T> r = new Iterators.Map<T,XSComponent>(nodeSet) {
protected Iterator<? extends T> apply(XSComponent contextNode) {
return filter(axis.iterator(contextNode));
}
};
// avoid duplicates
r = new Iterators.Unique<T>(r);
if(predicate>=0) {
T item=null;
for( int i=predicate; i>0; i-- ) {
if(!r.hasNext())
return Iterators.empty();
item = r.next();
}
return new Iterators.Singleton<T>(item);
}
return r;
}
/**
* Matches any name.
*/
static final class Any extends Step<XSComponent> {
public Any(Axis<? extends XSComponent> axis) {
super(axis);
}
// no filtering.
protected Iterator<? extends XSComponent> filter(Iterator<? extends XSComponent> base) {
return base;
}
}
private static abstract class Filtered<T extends XSComponent> extends Step<T> {
protected Filtered(Axis<? extends T> axis) {
super(axis);
}
protected Iterator<T> filter(Iterator<? extends T> base) {
return new Iterators.Filter<T>(base) {
protected boolean matches(T d) {
return match(d);
}
};
}
protected abstract boolean match(T d);
}
/**
* Matches a particular name.
*/
static final class Named extends Filtered<XSDeclaration> {
private final String nsUri;
private final String localName;
public Named(Axis<? extends XSDeclaration> axis, UName n) {
this(axis,n.getNamespaceURI(),n.getName());
}
public Named(Axis<? extends XSDeclaration> axis, String nsUri, String localName) {
super(axis);
this.nsUri = nsUri;
this.localName = localName;
}
protected boolean match(XSDeclaration d) {
return d.getName().equals(localName) && d.getTargetNamespace().equals(nsUri);
}
}
/**
* Matches anonymous types.
*/
static final class AnonymousType extends Filtered<XSType> {
public AnonymousType(Axis<? extends XSType> axis) {
super(axis);
}
protected boolean match(XSType node) {
return node.isLocal();
}
}
/**
* Matches a particular kind of facets.
*/
static final class Facet extends Filtered<XSFacet> {
private final String name;
public Facet(Axis<XSFacet> axis, String facetName) {
super(axis);
this.name = facetName;
}
protected boolean match(XSFacet f) {
return f.getName().equals(name);
}
}
/**
* Matches a schema in a particular namespace.
*/
static final class Schema extends Filtered<XSSchema> {
private final String uri;
public Schema(Axis<XSSchema> axis, String uri) {
super(axis);
this.uri = uri;
}
protected boolean match(XSSchema d) {
return d.getTargetNamespace().equals(uri);
}
}
}

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
package com.sun.xml.internal.xsom.impl.scd;
/**
* Describes the input token stream.
*/
public class Token {
/**
* An integer that describes the kind of this token. This numbering
* system is determined by JavaCCParser, and a table of these numbers is
* stored in the file ...Constants.java.
*/
public int kind;
/**
* beginLine and beginColumn describe the position of the first character
* of this token; endLine and endColumn describe the position of the
* last character of this token.
*/
public int beginLine, beginColumn, endLine, endColumn;
/**
* The string image of the token.
*/
public String image;
/**
* A reference to the next regular (non-special) token from the input
* stream. If this is the last token from the input stream, or if the
* token manager has not read tokens beyond this one, this field is
* set to null. This is true only if this token is also a regular
* token. Otherwise, see below for a description of the contents of
* this field.
*/
public Token next;
/**
* This field is used to access special tokens that occur prior to this
* token, but after the immediately preceding regular (non-special) token.
* If there are no such special tokens, this field is set to null.
* When there are more than one such special token, this field refers
* to the last of these special tokens, which in turn refers to the next
* previous special token through its specialToken field, and so on
* until the first special token (whose specialToken field is null).
* The next fields of special tokens refer to other special tokens that
* immediately follow it (without an intervening regular token). If there
* is no such token, this field is null.
*/
public Token specialToken;
/**
* Returns the image.
*/
public String toString()
{
return image;
}
/**
* Returns a new Token object, by default. However, if you want, you
* can create and return subclass objects based on the value of ofKind.
* Simply add the cases to the switch for all those special cases.
* For example, if you have a subclass of Token called IDToken that
* you want to create if ofKind is ID, simlpy add something like :
*
* case MyParserConstants.ID : return new IDToken();
*
* to the following switch statement. Then you can cast matchedToken
* variable to the appropriate type and use it in your lexical actions.
*/
public static final Token newToken(int ofKind)
{
switch(ofKind)
{
default : return new Token();
}
}
}

View File

@@ -0,0 +1,158 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
package com.sun.xml.internal.xsom.impl.scd;
public class TokenMgrError extends Error
{
/*
* Ordinals for various reasons why an Error of this type can be thrown.
*/
/**
* Lexical error occured.
*/
static final int LEXICAL_ERROR = 0;
/**
* An attempt wass made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
* one of the above 4 values.
*/
int errorCode;
/**
* Replaces unprintable characters by their espaced (or unicode escaped)
* equivalents in the given string
*/
protected static final String addEscapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
/**
* Returns a detailed message for the Error when it is thrown by the
* token manager to indicate a lexical error.
* Parameters :
* EOFSeen : indicates if EOF caused the lexicl error
* curLexState : lexical state in which this error occured
* errorLine : line number when the error occured
* errorColumn : column number when the error occured
* errorAfter : prefix that was seen before this error occured
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
/**
* You can also modify the body of this method to customize your error messages.
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
* of end-users concern, so you can return something like :
*
* "Internal Error : Please file a bug report .... "
*
* from this method for such cases in the release version of your parser.
*/
public String getMessage() {
return super.getMessage();
}
/*
* Constructors of various flavors follow.
*/
public TokenMgrError() {
}
public TokenMgrError(String message, int reason) {
super(message);
errorCode = reason;
}
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.util;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
* Aborts on the first error.
*/
public class DraconianErrorHandler implements ErrorHandler {
public void error( SAXParseException e ) throws SAXException {
throw e;
}
public void fatalError( SAXParseException e ) throws SAXException {
throw e;
}
public void warning( SAXParseException e ) {}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.util;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
public class ResourceEntityResolver implements EntityResolver {
public ResourceEntityResolver( Class _base ) {
this.base = _base;
}
private final Class base;
public InputSource resolveEntity( String publicId, String systemId ) {
return new InputSource(base.getResourceAsStream(systemId));
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,607 @@
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.xml.internal.xsom.impl.util;
import com.sun.xml.internal.xsom.XSAnnotation;
import com.sun.xml.internal.xsom.XSAttGroupDecl;
import com.sun.xml.internal.xsom.XSAttributeDecl;
import com.sun.xml.internal.xsom.XSAttributeUse;
import com.sun.xml.internal.xsom.XSComplexType;
import com.sun.xml.internal.xsom.XSContentType;
import com.sun.xml.internal.xsom.XSElementDecl;
import com.sun.xml.internal.xsom.XSFacet;
import com.sun.xml.internal.xsom.XSIdentityConstraint;
import com.sun.xml.internal.xsom.XSListSimpleType;
import com.sun.xml.internal.xsom.XSModelGroup;
import com.sun.xml.internal.xsom.XSModelGroupDecl;
import com.sun.xml.internal.xsom.XSNotation;
import com.sun.xml.internal.xsom.XSParticle;
import com.sun.xml.internal.xsom.XSRestrictionSimpleType;
import com.sun.xml.internal.xsom.XSSchema;
import com.sun.xml.internal.xsom.XSSchemaSet;
import com.sun.xml.internal.xsom.XSSimpleType;
import com.sun.xml.internal.xsom.XSType;
import com.sun.xml.internal.xsom.XSUnionSimpleType;
import com.sun.xml.internal.xsom.XSWildcard;
import com.sun.xml.internal.xsom.XSXPath;
import com.sun.xml.internal.xsom.XSWildcard.Any;
import com.sun.xml.internal.xsom.XSWildcard.Other;
import com.sun.xml.internal.xsom.XSWildcard.Union;
import com.sun.xml.internal.xsom.impl.Const;
import com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor;
import com.sun.xml.internal.xsom.visitor.XSTermVisitor;
import com.sun.xml.internal.xsom.visitor.XSVisitor;
import com.sun.xml.internal.xsom.visitor.XSWildcardFunction;
import java.io.IOException;
import java.io.Writer;
import java.math.BigInteger;
import java.text.MessageFormat;
import java.util.Iterator;
/**
* Generates approximated XML Schema representation from
* a schema component. This is not intended to be a fully-fledged
* round-trippable schema writer.
*
* <h2>Usage of this class</h2>
* <ol>
* <li>Create a new instance with whatever Writer
* you'd like to send the output to.
* <li>Call one of the overloaded dump methods.
* You can repeat this process as many times as you want.
* </ol>
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
* @author Kirill Grouchnikov (kirillcool@yahoo.com)
*/
public class SchemaWriter implements XSVisitor, XSSimpleTypeVisitor {
public SchemaWriter( Writer _out ) {
this.out=_out;
}
/** output is sent to this object. */
private final Writer out;
/** indentation. */
private int indent;
private void println(String s) {
try {
for( int i=0; i<indent; i++) out.write(" ");
out.write(s);
out.write('\n');
// flush stream to make the output appear immediately
out.flush();
} catch( IOException e ) {
// ignore IOException.
hadError = true;
}
}
private void println() { println(""); }
/** If IOException is encountered, this flag is set to true. */
private boolean hadError =false;
/** Flush the stream and check its error state. */
public boolean checkError() {
try {
out.flush();
} catch( IOException e ) {
hadError=true;
}
return hadError;
}
public void visit( XSSchemaSet s ) {
Iterator itr = s.iterateSchema();
while(itr.hasNext()) {
schema((XSSchema)itr.next());
println();
}
}
public void schema( XSSchema s ) {
// QUICK HACK: don't print the built-in components
if(s.getTargetNamespace().equals(Const.schemaNamespace))
return;
println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
indent++;
Iterator itr;
itr = s.iterateAttGroupDecls();
while(itr.hasNext())
attGroupDecl( (XSAttGroupDecl)itr.next() );
itr = s.iterateAttributeDecls();
while(itr.hasNext())
attributeDecl( (XSAttributeDecl)itr.next() );
itr = s.iterateComplexTypes();
while(itr.hasNext())
complexType( (XSComplexType)itr.next() );
itr = s.iterateElementDecls();
while(itr.hasNext())
elementDecl( (XSElementDecl)itr.next() );
itr = s.iterateModelGroupDecls();
while(itr.hasNext())
modelGroupDecl( (XSModelGroupDecl)itr.next() );
itr = s.iterateSimpleTypes();
while(itr.hasNext())
simpleType( (XSSimpleType)itr.next() );
indent--;
println("</schema>");
}
public void attGroupDecl( XSAttGroupDecl decl ) {
Iterator itr;
println(MessageFormat.format("<attGroup name=\"{0}\">", decl.getName()));
indent++;
// TODO: wildcard
itr = decl.iterateAttGroups();
while(itr.hasNext())
dumpRef( (XSAttGroupDecl)itr.next() );
itr = decl.iterateDeclaredAttributeUses();
while(itr.hasNext())
attributeUse( (XSAttributeUse)itr.next() );
indent--;
println("</attGroup>");
}
public void dumpRef( XSAttGroupDecl decl ) {
println(MessageFormat.format("<attGroup ref=\"'{'{0}'}'{1}\"/>", decl.getTargetNamespace(), decl.getName()));
}
public void attributeUse( XSAttributeUse use ) {
XSAttributeDecl decl = use.getDecl();
String additionalAtts="";
if(use.isRequired())
additionalAtts += " use=\"required\"";
if(use.getFixedValue()!=null && use.getDecl().getFixedValue()==null)
additionalAtts += " fixed=\""+use.getFixedValue()+'\"';
if(use.getDefaultValue()!=null && use.getDecl().getDefaultValue()==null)
additionalAtts += " default=\""+use.getDefaultValue()+'\"';
if(decl.isLocal()) {
// this is anonymous attribute use
dump(decl,additionalAtts);
} else {
// reference to a global one
println(MessageFormat.format("<attribute ref=\"'{'{0}'}'{1}{2}\"/>",
decl.getTargetNamespace(), decl.getName(), additionalAtts));
}
}
public void attributeDecl( XSAttributeDecl decl ) {
dump(decl,"");
}
private void dump( XSAttributeDecl decl, String additionalAtts ) {
XSSimpleType type=decl.getType();
println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
decl.getName(),
additionalAtts,
type.isLocal()?"":
MessageFormat.format(" type=\"'{'{0}'}'{1}\"", type.getTargetNamespace(), type.getName()),
decl.getFixedValue()==null ?
"":" fixed=\""+decl.getFixedValue()+'\"',
decl.getDefaultValue()==null ?
"":" default=\""+decl.getDefaultValue()+'\"',
type.isLocal()?"":" /"));
if(type.isLocal()) {
indent++;
simpleType(type);
indent--;
println("</attribute>");
}
}
public void simpleType( XSSimpleType type ) {
println(MessageFormat.format("<simpleType{0}>", type.isLocal()?"":" name=\""+type.getName()+'\"'));
indent++;
type.visit((XSSimpleTypeVisitor)this);
indent--;
println("</simpleType>");
}
public void listSimpleType( XSListSimpleType type ) {
XSSimpleType itemType = type.getItemType();
if(itemType.isLocal()) {
println("<list>");
indent++;
simpleType(itemType);
indent--;
println("</list>");
} else {
// global type
println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
itemType.getTargetNamespace(), itemType.getName()));
}
}
public void unionSimpleType( XSUnionSimpleType type ) {
final int len = type.getMemberSize();
StringBuffer ref = new StringBuffer();
for( int i=0; i<len; i++ ) {
XSSimpleType member = type.getMember(i);
if(member.isGlobal())
ref.append(MessageFormat.format(" '{'{0}'}'{1}", member.getTargetNamespace(),member.getName()));
}
if(ref.length()==0)
println("<union>");
else
println("<union memberTypes=\""+ref+"\">");
indent++;
for( int i=0; i<len; i++ ) {
XSSimpleType member = type.getMember(i);
if(member.isLocal())
simpleType(member);
}
indent--;
println("</union>");
}
public void restrictionSimpleType( XSRestrictionSimpleType type ) {
if(type.getBaseType()==null) {
// don't print anySimpleType
if(!type.getName().equals("anySimpleType"))
throw new InternalError();
if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
throw new InternalError();
return;
}
XSSimpleType baseType = type.getSimpleBaseType();
println(MessageFormat.format("<restriction{0}>",
baseType.isLocal()?"":" base=\"{"+
baseType.getTargetNamespace()+'}'+
baseType.getName()+'\"'));
indent++;
if(baseType.isLocal())
simpleType(baseType);
Iterator itr = type.iterateDeclaredFacets();
while(itr.hasNext())
facet( (XSFacet)itr.next() );
indent--;
println("</restriction>");
}
public void facet( XSFacet facet ) {
println(MessageFormat.format("<{0} value=\"{1}\"/>",
facet.getName(), facet.getValue()));
}
public void notation( XSNotation notation ) {
println(MessageFormat.format("<notation name='\"0}\" public =\"{1}\" system=\"{2}\" />",
notation.getName(), notation.getPublicId(), notation.getSystemId()));
}
public void complexType( XSComplexType type ) {
println(MessageFormat.format("<complexType{0}>",
type.isLocal()?"":" name=\""+type.getName()+'\"'));
indent++;
// TODO: wildcard
if(type.getContentType().asSimpleType()!=null) {
// simple content
println("<simpleContent>");
indent++;
XSType baseType = type.getBaseType();
if(type.getDerivationMethod()==XSType.RESTRICTION) {
// restriction
println(MessageFormat.format("<restriction base=\"<{0}>{1}\">",
baseType.getTargetNamespace(), baseType.getName()));
indent++;
dumpComplexTypeAttribute(type);
indent--;
println("</restriction>");
} else {
// extension
println(MessageFormat.format("<extension base=\"<{0}>{1}\">",
baseType.getTargetNamespace(), baseType.getName()));
// check if have redefine tag - Kirill
if( type.isGlobal()
&& type.getTargetNamespace().equals(baseType.getTargetNamespace())
&& type.getName().equals(baseType.getName())) {
indent++;
println("<redefine>");
indent++;
baseType.visit(this);
indent--;
println("</redefine>");
indent--;
}
indent++;
dumpComplexTypeAttribute(type);
indent--;
println("</extension>");
}
indent--;
println("</simpleContent>");
} else {
// complex content
println("<complexContent>");
indent++;
XSComplexType baseType = type.getBaseType().asComplexType();
if(type.getDerivationMethod()==XSType.RESTRICTION) {
// restriction
println(MessageFormat.format("<restriction base=\"'{'{0}'}'{1}\">",
baseType.getTargetNamespace(), baseType.getName()));
indent++;
type.getContentType().visit(this);
dumpComplexTypeAttribute(type);
indent--;
println("</restriction>");
} else {
// extension
println(MessageFormat.format("<extension base=\"'{'{0}'}'{1}\">",
baseType.getTargetNamespace(), baseType.getName()));
// check if have redefine - Kirill
if( type.isGlobal()
&& type.getTargetNamespace().equals(baseType.getTargetNamespace())
&& type.getName().equals(baseType.getName())) {
indent++;
println("<redefine>");
indent++;
baseType.visit(this);
indent--;
println("</redefine>");
indent--;
}
indent++;
type.getExplicitContent().visit(this);
dumpComplexTypeAttribute(type);
indent--;
println("</extension>");
}
indent--;
println("</complexContent>");
}
indent--;
println("</complexType>");
}
private void dumpComplexTypeAttribute( XSComplexType type ) {
Iterator itr;
itr = type.iterateAttGroups();
while(itr.hasNext())
dumpRef( (XSAttGroupDecl)itr.next() );
itr = type.iterateDeclaredAttributeUses();
while(itr.hasNext())
attributeUse( (XSAttributeUse)itr.next() );
XSWildcard awc = type.getAttributeWildcard();
if(awc!=null)
wildcard("anyAttribute",awc,"");
}
public void elementDecl( XSElementDecl decl ) {
elementDecl(decl,"");
}
private void elementDecl( XSElementDecl decl, String extraAtts ) {
XSType type = decl.getType();
// TODO: various other attributes
// qualified attr; Issue
if(decl.getForm() != null) {
extraAtts += " form=\"" + (decl.getForm() ? "qualified" : "unqualified" ) + "\"";
}
println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}>",
decl.getName(),
type.isLocal()?"":" type=\"{"+
type.getTargetNamespace()+'}'+
type.getName()+'\"',
extraAtts,
type.isLocal()?"":"/"));
if(type.isLocal()) {
indent++;
if(type.isLocal()) type.visit(this);
indent--;
println("</element>");
}
}
public void modelGroupDecl( XSModelGroupDecl decl ) {
println(MessageFormat.format("<group name=\"{0}\">", decl.getName()));
indent++;
modelGroup(decl.getModelGroup());
indent--;
println("</group>");
}
public void modelGroup( XSModelGroup group ) {
modelGroup(group,"");
}
private void modelGroup( XSModelGroup group, String extraAtts ) {
println(MessageFormat.format("<{0}{1}>", group.getCompositor(), extraAtts));
indent++;
final int len = group.getSize();
for( int i=0; i<len; i++ )
particle(group.getChild(i));
indent--;
println(MessageFormat.format("</{0}>", group.getCompositor()));
}
public void particle( XSParticle part ) {
BigInteger i;
StringBuilder buf = new StringBuilder();
i = part.getMaxOccurs();
if(i.equals(BigInteger.valueOf(XSParticle.UNBOUNDED)))
buf.append(" maxOccurs=\"unbounded\"");
else if(!i.equals(BigInteger.ONE))
buf.append(" maxOccurs=\"").append(i).append('\"');
i = part.getMinOccurs();
if(!i.equals(BigInteger.ONE))
buf.append(" minOccurs=\"").append(i).append('\"');
final String extraAtts = buf.toString();
part.getTerm().visit(new XSTermVisitor(){
public void elementDecl( XSElementDecl decl ) {
if(decl.isLocal())
SchemaWriter.this.elementDecl(decl,extraAtts);
else {
// reference
println(MessageFormat.format("<element ref=\"'{'{0}'}'{1}\"{2}/>",
decl.getTargetNamespace(),
decl.getName(),
extraAtts));
}
}
public void modelGroupDecl( XSModelGroupDecl decl ) {
// reference
println(MessageFormat.format("<group ref=\"'{'{0}'}'{1}\"{2}/>",
decl.getTargetNamespace(),
decl.getName(),
extraAtts));
}
public void modelGroup( XSModelGroup group ) {
SchemaWriter.this.modelGroup(group,extraAtts);
}
public void wildcard( XSWildcard wc ) {
SchemaWriter.this.wildcard("any",wc,extraAtts);
}
});
}
public void wildcard( XSWildcard wc ) {
wildcard("any",wc,"");
}
private void wildcard( String tagName, XSWildcard wc, String extraAtts ) {
final String proessContents;
switch(wc.getMode()) {
case XSWildcard.LAX:
proessContents = " processContents='lax'";break;
case XSWildcard.STRTICT:
proessContents = "";break;
case XSWildcard.SKIP:
proessContents = " processContents='skip'";break;
default:
throw new AssertionError();
}
println(MessageFormat.format("<{0}{1}{2}{3}/>",tagName, proessContents, wc.apply(WILDCARD_NS), extraAtts));
}
private static final XSWildcardFunction<String> WILDCARD_NS = new XSWildcardFunction<String>() {
public String any(Any wc) {
return ""; // default
}
public String other(Other wc) {
return " namespace='##other'";
}
public String union(Union wc) {
StringBuilder buf = new StringBuilder(" namespace='");
boolean first = true;
for (String s : wc.getNamespaces()) {
if(first) first=false;
else buf.append(' ');
buf.append(s);
}
return buf.append('\'').toString();
}
};
public void annotation( XSAnnotation ann ) {
// TODO: it would be nice even if we just put <xs:documentation>
}
public void identityConstraint(XSIdentityConstraint decl) {
// TODO
}
public void xpath(XSXPath xp) {
// TODO
}
public void empty( XSContentType t ) {}
}

View File

@@ -0,0 +1,187 @@
/*
Copyright (c) 2001, 2002 Thai Open Source Software Center Ltd
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 the Thai Open Source Software Center Ltd nor
the names of its 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 REGENTS 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.
*/
// @@3RD PARTY CODE@@
package com.sun.xml.internal.xsom.impl.util;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
public class Uri {
private static String utf8 = "UTF-8";
public static boolean isValid(String s) {
return isValidPercent(s) && isValidFragment(s) && isValidScheme(s);
}
private static final String HEX_DIGITS = "0123456789abcdef";
public static String escapeDisallowedChars(String s) {
StringBuffer buf = null;
int len = s.length();
int done = 0;
for (;;) {
int i = done;
for (;;) {
if (i == len) {
if (done == 0)
return s;
break;
}
if (isExcluded(s.charAt(i)))
break;
i++;
}
if (buf == null)
buf = new StringBuffer();
if (i > done) {
buf.append(s.substring(done, i));
done = i;
}
if (i == len)
break;
for (i++; i < len && isExcluded(s.charAt(i)); i++)
;
String tem = s.substring(done, i);
byte[] bytes;
try {
bytes = tem.getBytes(utf8);
}
catch (UnsupportedEncodingException e) {
utf8 = "UTF8";
try {
bytes = tem.getBytes(utf8);
}
catch (UnsupportedEncodingException e2) {
// Give up
return s;
}
}
for (int j = 0; j < bytes.length; j++) {
buf.append('%');
buf.append(HEX_DIGITS.charAt((bytes[j] & 0xFF) >> 4));
buf.append(HEX_DIGITS.charAt(bytes[j] & 0xF));
}
done = i;
}
return buf.toString();
}
private static String excluded = "<>\"{}|\\^`";
private static boolean isExcluded(char c) {
return c <= 0x20 || c >= 0x7F || excluded.indexOf(c) >= 0;
}
private static boolean isAlpha(char c) {
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}
private static boolean isHexDigit(char c) {
return ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F') || isDigit(c);
}
private static boolean isDigit(char c) {
return '0' <= c && c <= '9';
}
private static boolean isSchemeChar(char c) {
return isAlpha(c) || isDigit(c) || c == '+' || c == '-' || c =='.';
}
private static boolean isValidPercent(String s) {
int len = s.length();
for (int i = 0; i < len; i++)
if (s.charAt(i) == '%') {
if (i + 2 >= len)
return false;
else if (!isHexDigit(s.charAt(i + 1))
|| !isHexDigit(s.charAt(i + 2)))
return false;
}
return true;
}
private static boolean isValidFragment(String s) {
int i = s.indexOf('#');
return i < 0 || s.indexOf('#', i + 1) < 0;
}
private static boolean isValidScheme(String s) {
if (!isAbsolute(s))
return true;
int i = s.indexOf(':');
if (i == 0
|| i + 1 == s.length()
|| !isAlpha(s.charAt(0)))
return false;
while (--i > 0)
if (!isSchemeChar(s.charAt(i)))
return false;
return true;
}
public static String resolve(String baseUri, String uriReference) throws IOException {
if (isAbsolute(uriReference))
return uriReference;
if(baseUri==null)
throw new IOException("Unable to resolve relative URI "+uriReference+" without a base URI");
if(!isAbsolute(baseUri))
throw new IOException("Unable to resolve relative URI "+uriReference+" because base URI is not absolute: "+baseUri);
return new URL(new URL(baseUri), uriReference).toString();
}
public static boolean hasFragmentId(String uri) {
return uri.indexOf('#') >= 0;
}
public static boolean isAbsolute(String uri) {
int i = uri.indexOf(':');
if (i < 0)
return false;
while (--i >= 0) {
switch (uri.charAt(i)) {
case '#':
case '/':
case '?':
return false;
}
}
return true;
}
}