本文整理了Java中org.eclipse.xsd.XSDSchema
类的一些代码示例,展示了XSDSchema
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSDSchema
类的具体详情如下:
包路径:org.eclipse.xsd.XSDSchema
类名称:XSDSchema
[英]A representation of the model object 'Schema'.
The following features are supported:
代码示例来源:origin: geotools/geotools
Resource resource = schema.eResource();
if (resource == null) {
final ResourceSet resourceSet = new ResourceSetImpl();
resource = (XSDResourceImpl) resourceSet.createResource(URI.createURI(".xsd"));
resource.getContents().add(schema);
XSDImport imprt = XSDFactory.eINSTANCE.createXSDImport();
imprt.setNamespace(importee.getTargetNamespace());
schema.getContents().add(imprt);
resource.getResourceSet().getAdapterFactories().add(adapterFactory);
return imprt;
代码示例来源:origin: geotools/geotools
xsd.setSchemaForSchemaQNamePrefix("xsd");
xsd.getQNamePrefixToNamespaceMap().put("xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
xsd.setElementFormDefault(XSDForm.get(XSDForm.QUALIFIED));
xsd.setTargetNamespace(namespace);
xsd.getQNamePrefixToNamespaceMap().put(prefix, namespace);
String providedNamespace = simpleFeatureType.getName().getNamespaceURI();
String providedPrefix = (String) simpleFeatureType.getUserData().get("prefix");
xsd.getQNamePrefixToNamespaceMap().put(providedPrefix, providedNamespace);
XSDImport gml = factory.createXSDImport();
gml.setNamespace(gmlNamespace);
gml.setSchemaLocation(baseURL.toString() + "/" + gmlLocation);
gml.setResolvedSchema(gmlConfiguration.getXSD().getSchema());
xsd.getContents().add(gml);
xsd.getQNamePrefixToNamespaceMap().put("gml", gmlNamespace);
xsd.getQNamePrefixToNamespaceMap().put("gml", "http://www.opengis.net/gml");
XSDElementDeclaration _FEATURE = xsd.resolveElementDeclaration(gmlNamespace, "_Feature");
element.setSubstitutionGroupAffiliation(_FEATURE);
xsd.resolveComplexTypeDefinition(gmlNamespace, "AbstractFeatureType");
element.setTypeDefinition(featureType);
xsd.getContents().add(element);
xsd.updateElement();
return xsd;
代码示例来源:origin: geotools/geotools
/**
* Searches <code>schema</code> for an element which matches <code>name</code>.
*
* @param schema The schema
* @param name The element to search for
* @return The element declaration, or null if it could not be found.
*/
public static XSDElementDeclaration getElementDeclaration(XSDSchema schema, QName name) {
for (Iterator e = schema.getElementDeclarations().iterator(); e.hasNext(); ) {
XSDElementDeclaration element = (XSDElementDeclaration) e.next();
if (element.getTargetNamespace().equals(name.getNamespaceURI())) {
if (element.getName().equals(name.getLocalPart())) {
return element;
}
}
}
return null;
}
代码示例来源:origin: geoserver/geoserver
for (Iterator e = schema.getElementDeclarations().iterator(); e.hasNext(); ) {
XSDElementDeclaration element = (XSDElementDeclaration) e.next();
if (ft.getName().equals(element.getName())) {
type = element.getTypeDefinition();
break;
for (Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext(); ) {
XSDTypeDefinition typedef = (XSDTypeDefinition) t.next();
if ((ft.getName() + "_Type").equals(typedef.getName())) {
for (Iterator c = children.iterator(); c.hasNext(); ) {
XSDElementDeclaration ce = (XSDElementDeclaration) c.next();
if (at.getName().equals(ce.getName())) {
found = true;
if (ce.getContainer() instanceof XSDParticle) {
XSDParticle part = (XSDParticle) ce.getContainer();
at.setMinOccurs(part.getMinOccurs());
at.setMaxOccurs(part.getMaxOccurs());
代码示例来源:origin: geotools/geotools
private static boolean hasNoElementsNorTypes(XSDSchema schema) {
if (schema == null) {
return false;
}
return schema.getElementDeclarations().isEmpty() && schema.getTypeDefinitions().isEmpty();
}
代码示例来源:origin: geotools/geotools
public SchemaIndexImpl(XSDSchema[] schemas) {
this.schemas = new XSDSchema[schemas.length + 1];
adapter = new SchemaAdapter();
// set the schemas passed in
for (int i = 0; i < schemas.length; i++) {
this.schemas[i] = schemas[i];
synchronized (this.schemas[i].eAdapters()) {
this.schemas[i].eAdapters().add(adapter);
}
}
// add the schema for xml schema itself
this.schemas[schemas.length] = schemas[0].getSchemaForSchema();
}
代码示例来源:origin: geotools/geotools
if (config.getNamespaceURI().equals(schemas[i].getTargetNamespace())) {
found = true;
break O;
prefix != null ? new QName(uri, localName, prefix) : new QName(uri, localName);
XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent();
if (child.isElementDeclarationReference()) {
child = child.getResolvedElementDeclaration();
new QName(child.getTargetNamespace(), child.getName()),
parent,
this);
XSDElementDeclaration decl = XSDFactory.eINSTANCE.createXSDElementDeclaration();
decl.setName(qualifiedName.getLocalPart());
decl.setTargetNamespace(qualifiedName.getNamespaceURI());
代码示例来源:origin: geotools/geotools
for (Iterator itr = children.iterator(); itr.hasNext(); ) {
XSDParticle particle = (XSDParticle) itr.next();
XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent();
if (child.isElementDeclarationReference()) {
child = child.getResolvedElementDeclaration();
if (Encoder.COMMENT.equals(name)) {
encoder.getDocument().createElement(Encoder.COMMENT.getLocalPart());
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
XSDFactory.eINSTANCE.createXSDElementDeclaration();
elementDecl.setTargetNamespace(Encoder.COMMENT.getNamespaceURI());
elementDecl.setName(Encoder.COMMENT.getLocalPart());
elementDecl.setElement(comment);
particle.setContent(elementDecl);
particles.put(name, particle);
.resolveElementDeclaration(
name.getNamespaceURI(), name.getLocalPart());
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
XSDElementDeclaration wrapper = XSDFactory.eINSTANCE.createXSDElementDeclaration();
wrapper.setResolvedElementDeclaration(elementDecl);
代码示例来源:origin: geotools/geotools
for (Iterator itr = schema.getQNamePrefixToNamespaceMap().entrySet().iterator();
itr.hasNext(); ) {
Map.Entry entry = (Map.Entry) itr.next();
namespaces.declarePrefix("", schema.getTargetNamespace());
root = XSDFactory.eINSTANCE.createXSDElementDeclaration();
root.setName(name.getLocalPart());
root.setTargetNamespace(name.getNamespaceURI());
root.setTypeDefinition(type);
new QName(e.getTargetNamespace(), e.getName()),
context);
XSDParticle particle = (XSDParticle) tuple[0];
XSDElementDeclaration child =
(XSDElementDeclaration) particle.getContent();
if (particle.getMinOccurs() == 0) {
if (particle.isSetMaxOccurs()) {
maxOccurs = particle.getMaxOccurs();
} else {
代码示例来源:origin: geotools/geotools
protected void buildAttributeGroupIndex() {
attributeGroupIndex = new HashMap();
for (int i = 0; i < schemas.length; i++) {
XSDSchema schema = schemas[i];
for (Iterator g = schema.getAttributeGroupDefinitions().iterator(); g.hasNext(); ) {
XSDAttributeGroupDefinition group = (XSDAttributeGroupDefinition) g.next();
QName qName = new QName(group.getTargetNamespace(), group.getName());
attributeGroupIndex.put(qName, group);
}
}
}
代码示例来源:origin: org.geotools/gt2-xml-core
bindingName = new QName(type.getTargetNamespace(), type.getName());
} else {
for (Iterator e = type.getSchema().getElementDeclarations().iterator(); e.hasNext();) {
XSDElementDeclaration element = (XSDElementDeclaration) e.next();
if (type.equals(element.getAnonymousTypeDefinition())) {
bindingName = new QName(type.getTargetNamespace(), "_" + element.getName());
XSDParticle particle = Schemas.getChildElementParticle(container,
anonymous.getName(), true);
bindingName = new QName(container.getTargetNamespace(),
container.getName() + "_" + anonymous.getName());
代码示例来源:origin: geotools/geotools
protected void buildComplexTypeIndex() {
complexTypeIndex = new HashMap();
for (int i = 0; i < schemas.length; i++) {
XSDSchema schema = schemas[i];
for (Iterator t = schema.getTypeDefinitions().iterator(); t.hasNext(); ) {
XSDTypeDefinition type = (XSDTypeDefinition) t.next();
if (type instanceof XSDComplexTypeDefinition) {
QName qName = new QName(type.getTargetNamespace(), type.getName());
complexTypeIndex.put(qName, type);
}
}
}
}
代码示例来源:origin: geotools/geotools
protected void buildAttriubuteIndex() {
attributeIndex = new HashMap();
for (int i = 0; i < schemas.length; i++) {
XSDSchema schema = schemas[i];
for (Iterator a = schema.getAttributeDeclarations().iterator(); a.hasNext(); ) {
XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) a.next();
QName qName = new QName(attribute.getTargetNamespace(), attribute.getName());
attributeIndex.put(qName, attribute);
}
}
}
代码示例来源:origin: geotools/geotools
protected void buildElementIndex() {
elementIndex = new HashMap();
for (int i = 0; i < schemas.length; i++) {
XSDSchema schema = schemas[i];
for (Iterator e = schema.getElementDeclarations().iterator(); e.hasNext(); ) {
XSDElementDeclaration element = (XSDElementDeclaration) e.next();
QName qName = new QName(element.getTargetNamespace(), element.getName());
elementIndex.put(qName, element);
}
}
}
代码示例来源:origin: org.geoserver/gs-wfs
List contents = ftSchema.getContents();
schema.getContents().addAll(contents);
schema.updateElement();
XSDComplexTypeDefinition complexType = factory.createXSDComplexTypeDefinition();
complexType.setName(name + "Type");
schema.resolveComplexTypeDefinition(GML.NAMESPACE, "AbstractFeatureType"));
XSDModelGroup group = factory.createXSDModelGroup();
group.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
element.setTypeDefinition(type);
schema.getContents().add(complexType);
XSDElementDeclaration element = factory.createXSDElementDeclaration();
element.setSubstitutionGroupAffiliation(
schema.resolveElementDeclaration(GML.NAMESPACE, "_Feature"));
element.setTypeDefinition(complexType);
schema.getContents().add(element);
schema.updateElement();
代码示例来源:origin: geotools/geotools
XSDFactory factory = XSDFactory.eINSTANCE;
XSDComplexTypeDefinition definition = factory.createXSDComplexTypeDefinition();
definition.setName(type.getName().getLocalPart());
definition.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
XSDModelGroup attributes = factory.createXSDModelGroup();
attributes.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
Name anyName = new NameImpl(XS.NAMESPACE, XS.ANYTYPE.getLocalPart());
XSDElementDeclaration attribute = factory.createXSDElementDeclaration();
attribute.setName(attributeDescriptor.getLocalName());
attribute.setNillable(attributeDescriptor.isNillable());
if (xsd.resolveTypeDefinition(name.getNamespaceURI(), name.getLocalPart())
== null) {
throw new IllegalStateException(
"No type for "
+ attribute.getName()
+ " ("
+ binding.getName()
xsd.resolveTypeDefinition(name.getNamespaceURI(), name.getLocalPart());
attribute.setTypeDefinition(attributeDefinition);
xsd.getContents().add(definition);
代码示例来源:origin: geotools/geotools
bindingName = new QName(type.getTargetNamespace(), type.getName());
} else {
for (Iterator e = type.getSchema().getElementDeclarations().iterator(); e.hasNext(); ) {
XSDElementDeclaration element = (XSDElementDeclaration) e.next();
if (type.equals(element.getAnonymousTypeDefinition())) {
bindingName = new QName(type.getTargetNamespace(), "_" + element.getName());
if (e.isGlobal()) {
base = e;
new QName(
base.getTargetNamespace(),
base.getName() + "_" + anonymous.getName());
代码示例来源:origin: geotools/geotools
protected final AttributeType xsAnyType() {
XSDSchema schema = XSDUtil.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
for ( Iterator i = schema.getTypeDefinitions().iterator(); i.hasNext(); ) {
XSDTypeDefinition t = (XSDTypeDefinition) i.next();
if ( XS.ANYTYPE.getLocalPart().equals( t.getName() ) ) {
return findType(t);
}
}
throw new IllegalStateException("XS schema not present");
}
代码示例来源:origin: org.geoserver/gs-wfs
List resolvers = Schemas.findSchemaLocationResolvers(xmlConfiguration);
List locators = new ArrayList();
locators.add(
if (ftSchema.getSchemaForSchemaQNamePrefix() != null) {
schema.setSchemaForSchemaQNamePrefix(ftSchema.getSchemaForSchemaQNamePrefix());
List contents = ftSchema.getContents();
(XSDNamedComponent) content, schema.getElementDeclarations())) {
i.remove();
if (contains((XSDNamedComponent) content, schema.getTypeDefinitions())) {
i.remove();
XSDElementDeclaration element = factory.createXSDElementDeclaration();
element.setName(featureTypeMeta.getName());
for (Iterator t = ftSchema.getTypeDefinitions().iterator(); t.hasNext(); ) {
XSDTypeDefinition type = (XSDTypeDefinition) t.next();
if (type instanceof XSDComplexTypeDefinition) {
schema.getContents().add(element);
schema.getContents().addAll(contents);
schema.updateElement();
Schemas.dispose(ftSchema);
代码示例来源:origin: geotools/geotools
@Override
protected XSDSchema buildSchema() throws IOException {
XSDSchema schema = super.buildSchema();
schema.resolveElementDeclaration(NAMESPACE, "_Feature")
.eAdapters()
.add(new SubstitutionGroupLeakPreventer());
schema.eAdapters().add(new ReferencingDirectiveLeakPreventer());
return schema;
}
}
内容来源于网络,如有侵权,请联系作者删除!