ma2proto-xsom.1.97.source-code.xmlschema.rng Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of schema2proto-xsom Show documentation
Show all versions of schema2proto-xsom Show documentation
XML Schema Object Model (XSOM) is a Java library that allows applications to easily parse XML Schema
documents and inspect information in them. It is expected to be useful for applications that need to take XML
Schema as an input.
The newest version!
import com.sun.xml.xsom.*;
import com.sun.xml.xsom.parser.*;
import com.sun.xml.xsom.impl.*;
import com.sun.xml.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;
private String tns=null; // it defaults to the no namespace.
private Locator locator;
Attributes test = $runtime.getCurrentAttributes();
String tns = test.getValue("targetNamespace");
if(!includeMode) {
// importing
if(tns==null) tns=""; // if not present, then the empty namespace
$runtime.currentSchema = $runtime.parser.schemaSet.createSchema(tns,$runtime.copyLocator());
if(expectedNamespace!=null && !expectedNamespace.equals(tns)) {
$runtime.reportError(
Messages.format("UnexpectedTargetnamespace.Import", tns, expectedNamespace, tns ),
$runtime.getLocator());
}
} else {
// including
// check the consistency of @targetNamespace.
// @targetNamespace must be null or equal to the target namespace of the schema
if(tns!=null && expectedNamespace!=null && !expectedNamespace.equals(tns)) {
$runtime.reportError(
Messages.format("UnexpectedTargetnamespace.Include", tns, expectedNamespace, tns ) );
}
$runtime.chameleonMode = true;
}
// multiple inclusion test.
if( $runtime.hasAlreadyBeenRead() ) {
// skip this document
$runtime.redirectSubtree(new DefaultHandler(),"","","" );
return;
}
anno = (AnnotationImpl)$runtime.currentSchema.getAnnotation();
$runtime.blockDefault = 0;
$runtime.finalDefault = 0;
afd =
$runtime.attributeFormDefault = afd;
efd =
$runtime.elementFormDefault = efd;
$runtime.blockDefault=this.blockDefault.intValue();
$runtime.finalDefault=this.finalDefault.intValue();
fa = (null);
$runtime.currentSchema.addForeignAttributes(fa);
anno = (anno,AnnotationContext.SCHEMA);
$runtime.currentSchema.setAnnotation(anno);
locator = $runtime.copyLocator();
$runtime.checkDoubleDefError( $runtime.currentSchema.getElementDecl(e.getName()) );
$runtime.currentSchema.addElementDecl(e);
$runtime.checkDoubleDefError( $runtime.currentSchema.getType(st.getName()) );
$runtime.currentSchema.addSimpleType(st,false);
$runtime.checkDoubleDefError( $runtime.currentSchema.getType(ct.getName()) );
$runtime.currentSchema.addComplexType(ct,false);
locator = $runtime.copyLocator();
defaultValue = null;
fixedValue = null;
$runtime.checkDoubleDefError( $runtime.currentSchema.getAttributeDecl(ad.getName()) );
$runtime.currentSchema.addAttributeDecl(ad);
group =
$runtime.checkDoubleDefError( $runtime.currentSchema.getModelGroupDecl(group.getName()) );
$runtime.currentSchema.addModelGroupDecl(group,false);
$runtime.currentSchema.addNotation(notation);
$runtime.checkDoubleDefError( $runtime.currentSchema.getAttGroupDecl(ag.getName()) );
$runtime.currentSchema.addAttGroupDecl(ag,false);
import com.sun.xml.xsom.parser.AnnotationParser;
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);
}
locator = $runtime.copyLocator();
parser = $runtime.createAnnotationParser();
$runtime.redirectSubtree(parser.getContentHandler(
context,
$runtime.getAnnotationContextElementName(),
$runtime.getErrorHandler(),
$runtime.parser.getEntityResolver()
), $uri, $localName, $qname );
import java.util.StringTokenizer;
import java.util.LinkedHashSet;
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);
LinkedHashSet s = new LinkedHashSet();
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);
}
(null,AnnotationContext.WILDCARD);
fa = (null);
private Locator loc;
private XSNotation makeResult() {
return new NotationImpl( $runtime.document,ann,loc,fa,name,pub,sys);
}
loc = $runtime.copyLocator();
fa = (null);
(null,AnnotationContext.NOTATION);
text=qualified
text=unqualified
ForeignAttributesImpl makeResult() {
return $runtime.parseForeignAttributes(current);
}
import java.math.BigInteger;
BigInteger max = BigInteger.valueOf(1);
BigInteger min = BigInteger.valueOf(1);
max = new BigInteger(v);
unbounded
max=BigInteger.valueOf(-1);
min = new BigInteger(v);