/** * @see org.w3c.dom.TypeInfo#getTypeNamespace() */ public String getTypeNamespace() { if (type !=null){ return type.getNamespace(); } return null; }
public String getNamespace() { return xsTypeDefinition.getNamespace(); }
/** * Get a QName for a xs type * @param xstype * @return */ public QName getQName(XSTypeDefinition xstype) { String prefix = null; String ns = xstype.getNamespace(); String name = xstype.getName(); if (!ns.equals(xsNS)) prefix = Constants.PREFIX_TNS; else prefix = Constants.PREFIX_XSD; return new QName(ns, name, prefix); }
public boolean derivedFrom(String ancestorNS, String ancestorName, short derivation) { // REVISIT: implement according to derivation // ancestor is null, retur false if (ancestorName == null) return false; // ancestor is anyType, return true if (URI_SCHEMAFORSCHEMA.equals(ancestorNS) && ANY_TYPE.equals(ancestorName)) { return true; } // recursively get base, and compare it with ancestor XSTypeDefinition type = this; while (!(ancestorName.equals(type.getName()) && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor type != fAnySimpleType) { // reached anySimpleType type = type.getBaseType(); } return type != fAnySimpleType; }
private QName getQName( XSTypeDefinition xsType ) { QName name = null; if ( !xsType.getAnonymous() ) { name = new QName( xsType.getNamespace(), xsType.getName() ); } return name; }
public void removeXSTypeDefinition(XSTypeDefinition xst) { String ns = xst.getNamespace(); JBossXSNamespaceItem ni = nsimap.get(ns); ni.removeXSTypeDefinition(xst); anonymousMapper.rebuild(); }
/** * Get formatted string for the qname representing the xstype * @param xstype * @return */ public String getFormattedString(XSTypeDefinition xstype) { String ns = xstype.getNamespace(); String name = xstype.getName(); if (!ns.equals(xsNS)) name = getPrefix(ns) + ":" + name; return name; }
private void addRelatedType(XSTypeDefinition type, Vector componentList, String namespace, Hashtable dependencies) { if (!type.getAnonymous()) { if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(type.getNamespace())) { //REVISIT - do we use == instead if (!componentList.contains(type)) { final Vector importedNamespaces = findDependentNamespaces(namespace, dependencies); addNamespaceDependency(namespace, type.getNamespace(), importedNamespaces); componentList.add(type); } } } else { expandRelatedTypeComponents(type, componentList, namespace, dependencies); } }
private int getBaseType(XSTypeDefinition std) { if (std == null) { return XQItemType.XQBASETYPE_ANYSIMPLETYPE; } if (xs_ns.equals(std.getNamespace())) { QName qn = new QName(std.getNamespace(), std.getName()); int type = getBaseTypeForTypeName(qn); logger.trace("getBaseType; returning {} for type {}", type, std.getName()); return type; } return getBaseType(std.getBaseType()); }
public boolean derivedFrom(String ancestorNS, String ancestorName, short derivationMethod) { // ancestor is null, retur false if (ancestorName == null) return false; // ancestor is anyType, return true if (ancestorNS != null && ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) && ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) { return true; } // recursively get base, and compare it with ancestor XSTypeDefinition type = this; while (!(ancestorName.equals(type.getName()) && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor type != SchemaGrammar.fAnySimpleType && // reached anySimpleType !SchemaGrammar.isAnyType(type)) { // reached anyType type = (XSTypeDefinition)type.getBaseType(); } return type != SchemaGrammar.fAnySimpleType && !SchemaGrammar.isAnyType(type); }
public static boolean isSchemaTypesIdentical(XSTypeDefinition typeDefn1, XSTypeDefinition typeDefn2) { boolean typesIdentical = false; String type1Name = typeDefn1.getName(); String type2Name = typeDefn2.getName(); if (("anyType".equals(type1Name) && "anyType".equals(type2Name)) || ("anySimpleType".equals(type1Name) && "anySimpleType".equals(type2Name))) { typesIdentical = true; } if (!typesIdentical && isURIEqual(typeDefn1.getNamespace(), typeDefn2.getNamespace())) { // if targetNamespace of types are same, then check for equality of type names and of the base type if ((type1Name == null && type2Name == null) || (type1Name != null && type1Name.equals(type2Name)) && (isSchemaTypesIdentical(typeDefn1.getBaseType(), typeDefn2.getBaseType()))) { typesIdentical = true; } } return typesIdentical; } // isSchemaTypesIdentical
private void appendTypes(StringBuilder buffer, XSModel xsmodel) { XSNamedMap xsmap = xsmodel.getComponents(XSConstants.TYPE_DEFINITION); int len = xsmap != null ? xsmap.getLength() : 0; for (int i = 0; i < len; i++) { XSTypeDefinition xstype = (XSTypeDefinition)xsmap.item(i); if (Constants.NS_SCHEMA_XSD.equals(xstype.getNamespace())) continue; buffer.append(this.write(xstype)); } }
public void addXSTypeDefinition(XSTypeDefinition xst) { //Add type to the namespace item String ns = xst.getNamespace(); JBossXSNamespaceItem jbnm = createNamespaceItemIfNotExistent(ns); jbnm.addXSTypeDefinition(xst); anonymousMapper.rebuild(); }
private short getXercesXSDTypeCodeFor$value(XSTypeDefinition elementType) { if (Constants.NS_XMLSCHEMA.equals(elementType.getNamespace())) { short typeCode = -100; // dummy initializer boolean isxsd11Type = false; // the below 'if else' clauses are written to process few special cases handling few of schema types within PsychoPath XPath engine final String elementTypeName = elementType.getName(); if ("dayTimeDuration".equals(elementTypeName)) { typeCode = PsychoPathTypeHelper.DAYTIMEDURATION_DT; isxsd11Type = true; } else if ("yearMonthDuration".equals(elementTypeName)) { typeCode = PsychoPathTypeHelper.YEARMONTHDURATION_DT; isxsd11Type = true; } return (isxsd11Type) ? typeCode : ((XSSimpleTypeDefinition) elementType).getBuiltInKind(); } else { return getXercesXSDTypeCodeFor$value(elementType.getBaseType()); } } // getXercesXSDTypeCodeFor$value
void addGlobalTypeDecl(XSTypeDefinition decl) { final String namespace = decl.getNamespace(); final String declKey = (namespace == null || namespace.length() == 0) ? "," + decl.getName() : namespace + "," + decl.getName(); if (fGlobalTypeDecls.get(declKey) == null) { fGlobalTypeDecls.put(declKey, decl); } }
private void exportSimpleType( XMLStreamWriter writer, XSSimpleTypeDefinition simple ) throws XMLStreamException { writer.writeStartElement( "simpleType" ); if ( !simple.getAnonymous() ) { writer.writeAttribute( "name", simple.getName() ); } // TODO how can one find the derivation type? getFinal() is wrong! LOG.debug( "Exporting a simple type is done always by restriction. Other derivations may be possible?!" ); writer.writeStartElement( "restriction" ); QName qName = new QName( simple.getBaseType().getNamespace(), simple.getBaseType().getName() ); writer.writeAttribute( "base", getPrefixedName( qName ) ); StringList members = simple.getLexicalEnumeration(); if ( members != null && members.getLength() > 0 ) { for ( int i = 0; i < members.getLength(); i++ ) { writer.writeEmptyElement( "enumeration" ); writer.writeAttribute( "value", members.item( i ) ); } } writer.writeEndElement(); // derivation (restriction, extension, etc.) writer.writeEndElement(); // simpleType }
public QName getElementType(String namespaceUri, String localName) { XSElementDeclaration element = this.model.getElementDeclaration( localName, namespaceUri); XSTypeDefinition type = element.getTypeDefinition(); String typeNamespaceUri = type.getNamespace(); String typeName = type.getName(); return new QName(typeNamespaceUri, typeName); }
private void init() { // build lookup map to avoid usage of XSModel#getElementDeclaration(...) -- sometimes returns null for element // declarations that definitely exist (observed for XPlanGML 4.0 schemas with ADE) XSNamedMap elDecls = xsModel.getComponents( XSConstants.ELEMENT_DECLARATION ); for ( int i = 0; i < elDecls.getLength(); i++ ) { XSElementDeclaration elDecl = (XSElementDeclaration) elDecls.item( i ); QName name = new QName( elDecl.getNamespace(), elDecl.getName() ); nameToElDecl.put( name, elDecl ); } XSNamedMap typeDefs = xsModel.getComponents( XSConstants.TYPE_DEFINITION ); for ( int i = 0; i < typeDefs.getLength(); i++ ) { XSTypeDefinition typeDef = (XSTypeDefinition) typeDefs.item( i ); QName name = new QName( typeDef.getNamespace(), typeDef.getName() ); nameToTypeDef.put( name, typeDef ); } }
/** * Create a new JBossXSTypeDefinition * while reading data from a XSTypeDefinition * * @param xt */ public JBossXSTypeDefinition(XSTypeDefinition xt) { super(xt.getName(), xt.getNamespace()); setAnonymous(xt.getAnonymous()); XSTypeDefinition xbase = xt.getBaseType(); if (xbase != null) { if (xbase instanceof JBossXSTypeDefinition == false && !("anyType".equals(xbase.getName()))) baseType = new JBossXSTypeDefinition(xbase); } }
String generateTypeHierarchy( XSTypeDefinition type, String indent ) { String s = "\n" + indent + "-> '" + type.getName() + "' (" + type.getNamespace() + "'): "; switch ( type.getTypeCategory() ) { case XSTypeDefinition.SIMPLE_TYPE: { s += "simple"; break; } case XSTypeDefinition.COMPLEX_TYPE: { s += "complex"; break; } default: { // cannot happen } } if ( type.getBaseType() != null && type.getBaseType() != type ) { s += generateTypeHierarchy( type.getBaseType(), " " + indent ); } return s; }