com.sun.xml.xsom.XSType Java Examples
The following examples show how to use
com.sun.xml.xsom.XSType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Util.java From jolie with GNU Lesser General Public License v2.1 | 6 votes |
/** * 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; } }
Example #2
Source File: XsdToJolieConverterImpl.java From jolie with GNU Lesser General Public License v2.1 | 6 votes |
private TypeDefinition createSimpleType( XSType type, XSElementDecl element, Range range ) { checkType( type ); TypeInlineDefinition right = new TypeInlineDefinition( PARSING_CONTEXT, element.getName().replace( "-", "_" ), XsdUtils.xsdToNativeType( type.getName() ), range ); if( element.isNillable() ) { TypeInlineDefinition left = new TypeInlineDefinition( PARSING_CONTEXT, element.getName().replace( "-", "_" ), NativeType.VOID, range ); return new TypeChoiceDefinition( PARSING_CONTEXT, element.getName().replace( "-", "_" ), range, left, right ); } else { return right; } }
Example #3
Source File: SchemaTreeTraverser.java From jolie with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates node for element declaration with additional attributes. * * @param decl Element declaration. * @param extraAtts Additional attributes. */ private void elementDecl(XSElementDecl decl, String extraAtts) { XSType type = decl.getType(); // TODO: various other attributes String str = MessageFormat.format("Element name=\"{0}\"{1}{2}", new Object[]{ decl.getName(), type.isLocal() ? "" : " type=\"{" + type.getTargetNamespace() + "}" + type.getName() + "\"", extraAtts}); SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator()); this.currNode.add(newNode); this.currNode = newNode; if (type.isLocal()) { if (type.isLocal()) { type.visit(this); } } this.currNode = (SchemaTreeNode) this.currNode.getParent(); }
Example #4
Source File: SchemaWriter.java From jolie with GNU Lesser General Public License v2.1 | 6 votes |
private void elementDecl( XSElementDecl decl, String extraAtts ) { XSType type = decl.getType(); // TODO: various other attributes println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}>", new Object[]{ 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>"); } }
Example #5
Source File: ElementDecl.java From citygml4j with Apache License 2.0 | 6 votes |
private boolean isDerivedFromComplexType(XSSchema schema, String localPart) { XSType base = schema.getType(localPart); if (base != null) { if (base.isSimpleType()) { typeFlag.add(TypeFlag.NO_ABSTRACT_GML); typeFlag.add(TypeFlag.NO_FEATURE); typeFlag.add(TypeFlag.NO_FEATURE_COLLECTION); typeFlag.add(TypeFlag.NO_CITY_OBJECT); typeFlag.add(TypeFlag.NO_GEOMETRY); typeFlag.add(TypeFlag.NO_FEATURE_PROPERTY); typeFlag.add(TypeFlag.NO_GEOMETRY_PROPERTY); return false; } else return element.getType().isDerivedFrom(base); } return false; }
Example #6
Source File: ComplexTypeImpl.java From jolie with GNU Lesser General Public License v2.1 | 6 votes |
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<XSAttGroupDecl> itr = iterateAttGroups(); while(itr.hasNext() && o==null) o = itr.next().getAttributeUse(nsURI,localName); } if(o==null) { XSType base = getBaseType(); if(base.asComplexType()!=null) o = base.asComplexType().getAttributeUse(nsURI,localName); } return o; }
Example #7
Source File: XmlFormBuilder.java From dynaform with Artistic License 2.0 | 5 votes |
public XmlForm elementDecl(XSElementDecl decl) { if (log.isDebugEnabled()) log.debug("Element Declaration: " + decl); XSType type = decl.getType(); if (type.isSimpleType()) return elementDeclSimple(decl, type.asSimpleType()); else return elementDeclComplex(decl, type.asComplexType()); }
Example #8
Source File: Util.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
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 ); } }
Example #9
Source File: Util.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
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()]); }
Example #10
Source File: SimpleTypeImpl.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
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; } }
Example #11
Source File: ElementDecl.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
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( (rd && rused) || ( ed && eused ) ) continue; // this element can substitute "parent" parent.addSubstitutable(this); } }
Example #12
Source File: ComplexTypeImpl.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
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; } }
Example #13
Source File: ComplexTypeImpl.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
public XSWildcard getAttributeWildcard() { WildcardImpl complete = localAttWildcard; Iterator<XSAttGroupDecl> itr = iterateAttGroups(); while( itr.hasNext() ) { WildcardImpl w = (WildcardImpl)(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); }
Example #14
Source File: Schema.java From citygml4j with Apache License 2.0 | 5 votes |
public boolean haveSameTypeDefinition(List<ElementDecl> elementDecls) { Iterator<ElementDecl> iter = elementDecls.iterator(); ElementDecl first = iter.next(); XSType refType = first.getXSElementDecl().getType(); while (iter.hasNext()) if (iter.next().getXSElementDecl().getType() != refType) return false; return true; }
Example #15
Source File: XmlUtils.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
private static void _valueToDocument( Value value, Element element, Document doc, XSType type ) { addForcedAttribute( value, element ); if( type.isSimpleType() ) { element.appendChild( doc.createTextNode( value.strValue() ) ); } else if( type.isComplexType() ) { String name; Value currValue; XSComplexType complexType = type.asComplexType(); // Iterate over attributes Collection< ? extends XSAttributeUse > attributeUses = complexType.getAttributeUses(); for( XSAttributeUse attrUse : attributeUses ) { name = attrUse.getDecl().getName(); if( (currValue = getAttributeOrNull( value, name )) != null ) { element.setAttribute( name, currValue.strValue() ); } } XSContentType contentType = complexType.getContentType(); XSParticle particle = contentType.asParticle(); if( contentType.asSimpleType() != null ) { element.appendChild( doc.createTextNode( value.strValue() ) ); } else if( particle != null ) { XSTerm term = particle.getTerm(); XSModelGroupDecl modelGroupDecl; XSModelGroup modelGroup = null; if( (modelGroupDecl = term.asModelGroupDecl()) != null ) { modelGroup = modelGroupDecl.getModelGroup(); } else if( term.isModelGroup() ) { modelGroup = term.asModelGroup(); } if( modelGroup != null ) { _valueToDocument( value, element, doc, modelGroup ); } } } }
Example #16
Source File: ReadingRemoteADE.java From citygml4j with Apache License 2.0 | 5 votes |
static void checkADE(SchemaHandler schemaHandler, Element element, ElementDecl parent, int level) { System.out.print(indent(level) + element.getLocalName()); Schema schema = schemaHandler.getSchema(element.getNamespaceURI()); ElementDecl decl = null; if (schema != null) { decl = schema.getElementDecl(element.getLocalName(), parent); if (decl != null) { if (decl.isCityObject()) System.out.print(" [CITYOBJECT]"); else if (decl.isFeature()) System.out.print(" [FEATURE]"); else if (decl.isGeometry()) System.out.print(" [GEOMETRY]"); else if (decl.isFeatureProperty()) System.out.print(" [FEATURE_PROPERTY]"); else if (decl.isGeometryProperty()) System.out.print(" [GEOMETRY_PROPERTY]"); XSType type = decl.getXSElementDecl().getType(); System.out.println(": " + type.getName() + "{" + type.getTargetNamespace() + "}"); } } parent = decl; NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) checkADE(schemaHandler, (Element)child, parent, level + 1); } if (element.getFirstChild().getNodeType() == Node.TEXT_NODE) System.out.println(indent(level) + "--> " + element.getFirstChild().getNodeValue()); }
Example #17
Source File: XsdToJolieConverterImpl.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
/** * Checks whether a native type for a given simple type is defined. */ private void checkForNativeType( XSType type, String msg ) throws ConversionException { if( XsdUtils.xsdToNativeType( type.getName() ) == null ) { if( !strict() ) { log( Level.WARNING, msg + " Name: " + type.getName() ); } else { throw new ConversionException( ERROR_SIMPLE_TYPE + msg + " Name: " + type.getName() ); } } }
Example #18
Source File: SchemaSetImpl.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
public Iterator<XSType> iterateTypes() { return new Iterators.Map<XSType,XSSchema>(iterateSchema()) { protected Iterator<XSType> apply(XSSchema u) { return u.iterateTypes(); } }; }
Example #19
Source File: ReadingLocalADE.java From citygml4j with Apache License 2.0 | 5 votes |
static void checkADE(SchemaHandler schemaHandler, Element element, ElementDecl parent, int level) { System.out.print(indent(level) + element.getLocalName()); Schema schema = schemaHandler.getSchema(element.getNamespaceURI()); ElementDecl decl = null; if (schema != null) { decl = schema.getElementDecl(element.getLocalName(), parent); if (decl != null) { if (decl.isCityObject()) System.out.print(" [CITYOBJECT]"); else if (decl.isFeature()) System.out.print(" [FEATURE]"); else if (decl.isGeometry()) System.out.print(" [GEOMETRY]"); else if (decl.isFeatureProperty()) System.out.print(" [FEATURE_PROPERTY]"); else if (decl.isGeometryProperty()) System.out.print(" [GEOMETRY_PROPERTY]"); XSType type = decl.getXSElementDecl().getType(); System.out.println(": " + type.getName() + "{" + type.getTargetNamespace() + "}"); } } parent = decl; NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) checkADE(schemaHandler, (Element)child, parent, level + 1); } if (element.getFirstChild().getNodeType() == Node.TEXT_NODE) System.out.println(indent(level) + "--> " + element.getFirstChild().getNodeValue()); }
Example #20
Source File: TypeClosure.java From jolie with GNU Lesser General Public License v2.1 | 5 votes |
public boolean contains(XSType type) { if( typeSet.contains(type) ) { return true; } else { XSType baseType = type.getBaseType(); if( baseType == null ) { return false; } else { // climb the super type hierarchy return contains(baseType); } } }
Example #21
Source File: SchemaWriter.java From citygml4j with Apache License 2.0 | 4 votes |
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" ) + "\""; } StringBuffer buf = new StringBuffer(); XSElementDecl substGrp = decl.getSubstAffiliation(); if (substGrp != null) { buf.append(" substitutionGroup=\"{") .append(substGrp.getTargetNamespace()) .append("}") .append(substGrp.getName()) .append("\""); } println(MessageFormat.format("<element name=\"{0}\"{1}{2}{3}{4}>", decl.getName(), type.isLocal()?"":" type=\"{"+ type.getTargetNamespace()+'}'+ type.getName()+'\"', extraAtts, buf.toString(), type.isLocal()?"":"/")); if(type.isLocal()) { indent++; if(type.isLocal()) type.visit(this); indent--; println("</element>"); } else { } }
Example #22
Source File: Util.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public static XSType[] listSubstitutables( XSType _this ) { Set substitables = new HashSet(); buildSubstitutables( _this, substitables ); return (XSType[]) substitables.toArray(new XSType[substitables.size()]); }
Example #23
Source File: SchemaImpl.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public Map<String,XSType> getTypes() { return allTypesView; }
Example #24
Source File: SchemaImpl.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public XSType getType(String name) { return allTypes.get(name); }
Example #25
Source File: SchemaImpl.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public Iterator<XSType> iterateTypes() { return allTypes.values().iterator(); }
Example #26
Source File: Axis.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public Iterator<XSType> attributeDecl(XSAttributeDecl decl) { return singleton(decl.getType()); }
Example #27
Source File: Axis.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public Iterator<XSType> elementDecl(XSElementDecl decl) { return singleton(decl.getType()); }
Example #28
Source File: Axis.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public Iterator<XSType> simpleType(XSSimpleType type) { return singleton(type.getBaseType()); }
Example #29
Source File: Axis.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public Iterator<XSType> complexType(XSComplexType type) { return singleton(type.getBaseType()); }
Example #30
Source File: Step.java From jolie with GNU Lesser General Public License v2.1 | 4 votes |
public AnonymousType(Axis<? extends XSType> axis) { super(axis); }