/** * Returns a list of all child element declarations of the specified * type, no order is guaranteed. * <p> * The <code>includeParents</code> flag controls if this method should * returns those elements defined on parent types. * </p> * @param type The type * @param includeParents flag indicating if parent types should be processed * * @return A list of @link XSDElementDeclaration objects, one for each * child element. */ public static final List getChildElementDeclarations(XSDTypeDefinition type, boolean includeParents) { List particles = getChildElementParticles(type, includeParents); List elements = new ArrayList(); for (Iterator p = particles.iterator(); p.hasNext();) { XSDParticle particle = (XSDParticle) p.next(); XSDElementDeclaration decl = (XSDElementDeclaration) particle.getContent(); if (decl.isElementDeclarationReference()) { decl = decl.getResolvedElementDeclaration(); } elements.add(decl); } return elements; }
/** * Parses a schema at the specified location. * * @param location A uri pointing to the location of the schema. * * @return The parsed schema, or null if the schema could not be parsed. * * @throws IOException In the event of a schema parsing error. */ public static final XSDSchema parse(String location) throws IOException { return parse(location, Collections.EMPTY_LIST, Collections.EMPTY_LIST); }
/** * Returns a list of all attribute declarations declared in the type (or * any base type) of the specified element. * * <p> * This method is just a shortcut for {@link #getAttributeDeclarations(XSDTypeDefinition) getAttributeDeclarations(element.getType()} * </p> * * @param element The element. * * @return A list of @link XSDAttributeDeclaration objects, one for each * attribute of the element. */ public static final List getAttributeDeclarations(XSDElementDeclaration element) { return getAttributeDeclarations(element.getType()); }
/** * Returns an attribute declaration that is contained in the type of another * element declaration. * * @param element The containing element declaration. * @param qName The qualified name of the contained attribute * * @return The contained attribute declaration, or false if containment is * not satisfied. */ public static final XSDAttributeDeclaration getAttributeDeclaration( XSDElementDeclaration element, QName qName) { List atts = getAttributeDeclarations(element); for (Iterator itr = atts.iterator(); itr.hasNext();) { XSDAttributeDeclaration att = (XSDAttributeDeclaration) itr.next(); if (nameMatches(att, qName)) { return att; } } return null; }
schemas[i / 2] = Schemas.parse(location, locators, resolvers); } catch (Exception e) { String msg = "Error parsing: " + location; O: for (int i = 0; i < schemas.length; i++) { List imports = Schemas.getImports(schemas[i]); QName qualifiedName = new QName(uri, localName); XSDElementDeclaration element = index.getElementDeclaration(qualifiedName); List childParticles = index.getChildElementParticles(parentElement .getElementDeclaration()); XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent(); if (child.isElementDeclarationReference()) { child = child.getResolvedElementDeclaration(); handler = handlerFactory.createElementHandler(new QName( child.getTargetNamespace(), child.getName()), parent, this); handler = (ElementHandler) parent.createChildHandler(new QName("*", qualifiedName.getLocalPart()));
String name = attributes.getLocalName(i); QName attQName = new QName(uri, name); XSDAttributeDeclaration decl = Schemas.getAttributeDeclaration(content, attQName); decl.setName(attQName.getLocalPart()); decl.setTargetNamespace(attQName.getNamespaceURI()); .getSimpleTypeIdMap() .get("string");
List children = encoder.getSchemaIndex().getChildElementParticles(element); XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent(); if (child.isElementDeclarationReference()) { child = child.getResolvedElementDeclaration(); if (Encoder.COMMENT.equals(name)) { .createElement(Encoder.COMMENT.getLocalPart()); particle.setContent(elementDecl); particles.put(name, particle); .getElementDeclaration(name); .resolveElementDeclaration(name.getNamespaceURI(), name.getLocalPart()); for ( Iterator p = Schemas.getChildElementParticles(element.getType(), true).iterator(); p.hasNext(); ) { XSDParticle particle = (XSDParticle) p.next(); XSDElementDeclaration el = (XSDElementDeclaration) particle.getContent(); if ( el.isElementDeclarationReference() ) { el = el.getResolvedElementDeclaration(); if ( Schemas.isBaseType(elementDecl, el) ) { reference = particle; break;
children = new ListOrderedMap(); for (Iterator i = Schemas.getChildElementParticles(parent.getType(), true) .iterator(); i.hasNext();) { XSDParticle particle = (XSDParticle) i.next(); XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent(); if (child.isElementDeclarationReference()) { child = child.getResolvedElementDeclaration(); if (child.getTargetNamespace() != null) { childName = new QName(child.getTargetNamespace(), child.getName()); } else if (parent.getTargetNamespace() != null) { childName = new QName(parent.getTargetNamespace(), child.getName()); } else if (parent.getType().getTargetNamespace() != null) { childName = new QName(parent.getType().getTargetNamespace(), child.getName()); } else {
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());
namespace = element.getTargetNamespace(); XSDTypeDefinition type = schemaIndex.getTypeDefinition(new QName(namespace, typeName)); XSDElementDeclaration e = schemaIndex.getElementDeclaration(new QName(namespace, typeName)); type = e.getTypeDefinition(); List particles = Schemas.getChildElementParticles(type, true); List properties = new ArrayList(); XSDElementDeclaration attribute = (XSDElementDeclaration) particle.getContent(); if (attribute.isElementDeclarationReference()) { attribute = attribute.getResolvedElementDeclaration();
ftSchema = Schemas.parse(schemaFile.file().getAbsolutePath(), locators, null); } catch (IOException e) { LOGGER.log( List contents = ftSchema.getContents(); schema.getContents().addAll(contents); schema.updateElement(); element.setName(attribute.getLocalName()); element.setNillable(attribute.isNillable()); index.getTypeDefinition( new QName(typeName.getNamespaceURI(), typeName.getLocalPart())); if (type == null) { throw new IllegalStateException("Could not find type: " + typeName); element.setTypeDefinition(type); particle.setMinOccurs(attribute.getMinOccurs()); particle.setMaxOccurs(attribute.getMaxOccurs()); particle.setContent(element); group.getContents().add(particle);
public List getProperties(Object object, XSDElementDeclaration element) throws Exception { List<Object[/* 2 */]> properties = new ArrayList<Object[/* 2 */]>(); XSDTypeDefinition typeDef = element.getTypeDefinition(); boolean isAnyType = typeDef.getName() != null && typeDef.getTargetNamespace() != null && typeDef.getName().equals(XS.ANYTYPE.getLocalPart()) && typeDef.getTargetNamespace().equals(XS.NAMESPACE); if (isAnyType) { for (XSDParticle childParticle : (List<XSDParticle>) Schemas.getChildElementParticles( element.getTypeDefinition(), true)) { XSDElementDeclaration childElement = (XSDElementDeclaration) childParticle .getContent(); .getAnyElementParticles(element.getTypeDefinition())); if (anyElementParticles.size() > 0) { Collection complexAtts = null; .getChildElementParticles(element.getTypeDefinition(), false)); for (Object complex : complexAtts) { if (complex instanceof ComplexAttribute) {
/** * TODO: add connectionfactory parameter to handle authentication, gzip, etc * * @param featureTypeName * @param schemaLocation * @return */ private static XSDElementDeclaration parseFeatureType( final QName featureTypeName, final URL schemaLocation) throws DataSourceException { ApplicationSchemaConfiguration configuration; { String namespaceURI = featureTypeName.getNamespaceURI(); String uri = schemaLocation.toExternalForm(); configuration = new ApplicationSchemaConfiguration(namespaceURI, uri); } SchemaIndex schemaIndex; try { schemaIndex = Schemas.findSchemas(configuration); } catch (RuntimeException e) { throw new DataSourceException("Error parsing feature type for " + featureTypeName, e); } XSDElementDeclaration elementDeclaration; elementDeclaration = schemaIndex.getElementDeclaration(featureTypeName); schemaIndex.destroy(); if (elementDeclaration == null) { throw new DataSourceException("No XSDElementDeclaration found for " + featureTypeName); } return elementDeclaration; }
descriptor.getUserData().put("substitutionGroup", substitutionGroup); int minOccurs = Schemas.getMinOccurs(container, elemDecl); int maxOccurs = Schemas.getMaxOccurs(container, elemDecl); boolean nillable = elemDecl.isNillable(); Iterator substitutions = elemDecl.getSubstitutionGroup().iterator(); XSDElementDeclaration sub; while (substitutions.hasNext()) { sub = (XSDElementDeclaration) substitutions.next(); if (!(sub.getName().equals(elemDecl.getName())) || !(sub.getTargetNamespace().equals(elemDecl.getTargetNamespace()))) { Name elemName = Types.typeName(sub.getTargetNamespace(), sub.getName()); Collection<PropertyDescriptor> children = complexType.getDescriptors(); List<XSDParticle> childParticles = Schemas.getChildElementParticles(typeDef, true); .getContent(); if (element.isElementDeclarationReference()) {
BindingWalkerFactory bwFactory) throws Exception { SimpleFeatureTypeBuilder ftBuilder = new SimpleFeatureTypeBuilder(); ftBuilder.setName(element.getName()); ftBuilder.setNamespaceURI(element.getTargetNamespace()); List children = Schemas.getChildElementParticles(element.getType(), true); XSDElementDeclaration property = (XSDElementDeclaration) particle.getContent(); if (property.isElementDeclarationReference()) { int min = particle.getMinOccurs(); int max = particle.getMaxOccurs();
List resolvers = Schemas.findSchemaLocationResolvers(xmlConfiguration); List locators = new ArrayList(); locators.add( ftSchema = Schemas.parse(schemaFile.file().getAbsolutePath(), locators, resolvers); } catch (IOException e) { logger.log( if (ftSchema.getSchemaForSchemaQNamePrefix() != null) { schema.setSchemaForSchemaQNamePrefix(ftSchema.getSchemaForSchemaQNamePrefix()); if (name.equals(element.getName()) && featureTypeMeta .getNamespace() .getURI() .equals(element.getTargetNamespace())) { hasElement = true; element.setName(featureTypeMeta.getName()); element.setTargetNamespace(featureTypeMeta.getNamespace().getURI()); synchronized (Schemas.class) { schema.updateElement(); Schemas.dispose(ftSchema);
Schemas.getChildElementParticle(element.getType(), "Name", false), property.getName() }); (newTypeName != null) ? index.getTypeDefinition(newTypeName) : null; value.setName("Value"); value.setTypeDefinition(type); particle.setMinOccurs(1); particle.setMaxOccurs(1); particle.setContent(value); Schemas.getChildElementParticle(element.getType(), "Value", false), property.getValue() };
complexTypeDef = (XSDComplexTypeDefinition) typeDefinition; boolean includeParents = true; List<XSDElementDeclaration> children = Schemas.getChildElementDeclarations(typeDefinition, includeParents); } catch (NoSuchElementException e) { String msg = "Failed to create descriptor for '" + childDecl.getTargetNamespace() + "#" + childDecl.getName() + " from container '" + typeDefinition.getTargetNamespace() + "#" + typeDefinition.getName() + "'"; if (elemDecl.isElementDeclarationReference()) { elemDecl = elemDecl.getResolvedElementDeclaration();
/** * Returns a list of all child element declarations of the specified * element, no order is guaranteed. * * @param element The parent element. * * @return A list of @link XSDElementDeclaration objects, one for each * child element. * * @deprecated use {@link #getChildElementDeclarations(XSDTypeDefinition)} */ public static final List getChildElementDeclarations(XSDElementDeclaration element) { return getChildElementDeclarations(element.getType()); }
schema = Schemas.parse(getSchemaLocation(), Collections.EMPTY_LIST, Collections.singletonList(new XSDSchemaLocationResolver() { public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, schema.resolveElementDeclaration(NAMESPACE, "_Feature").eAdapters() .add(new SubstitutionGroupLeakPreventer()); schema.eAdapters().add(new ReferencingDirectiveLeakPreventer()); return schema;