String toString( XSSimpleTypeDefinition simpleType ) { String s = "\n - simple type: '" + simpleType.getName() + "' (" + simpleType.getNamespace() + ")"; XSTypeDefinition baseType = simpleType.getBaseType(); if ( baseType != null ) { s += "\n - type hierarchy:"; s += generateTypeHierarchy( baseType, " " ); } return s; }
public short getBuiltInKind() { return xsSimple.getBuiltInKind(); }
public XSObjectList getFacets() { return xsSimple.getFacets(); }
/** * Create a QName given a Simple Type * @param xs * @return qname */ public static QName createQNameFromXSSimpleType(XSSimpleTypeDefinition xs) { String nsuri = xs.getNamespace(); String localpart = xs.getName(); if (xsNS.equals(nsuri)) return new QName(nsuri, localpart, Constants.PREFIX_XSD); else return new QName(nsuri, localpart); }
/** * Checks if a type is derived from another by list. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by list for the reference type */ private boolean isDerivedByList (String ancestorNS, String ancestorName, XSTypeDefinition type) { // If the variety is union if (type !=null && ((XSSimpleTypeDefinition)type).getVariety() == VARIETY_LIST) { // get the {item type} XSTypeDefinition itemType = ((XSSimpleTypeDefinition)type).getItemType(); // T2 is the {item type definition} if (itemType != null) { // T2 is derived from the other type definition by DERIVATION_RESTRICTION if (isDerivedByRestriction(ancestorNS, ancestorName, itemType)) { return true; } } } return false; }
public static String generateSampleValue(GeneratorConfig config, XSSimpleTypeDefinition simpleType, String hint, Map<String, Integer> counters) { if (simpleType.getBuiltInKind() == XSConstants.LIST_DT) { XSSimpleTypeDefinition itemType = simpleType.getItemType(); } else if (simpleType.getMemberTypes().getLength() > 0) { XSObjectList members = simpleType.getMemberTypes(); int rand = RandomUtil.random(0, members.getLength() - 1); return generateSampleValue(config, (XSSimpleTypeDefinition) members.item(rand), hint, counters); while (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(builtInType.getNamespace())) { builtInType = (XSSimpleTypeDefinition) builtInType.getBaseType(); String name = builtInType.getName().toLowerCase(); if ("boolean".equals(name)) { return RandomUtil.randomBoolean() ? "true" : "false"; StringList pattern = simpleType.getLexicalPattern(); if (pattern != null && !pattern.isEmpty()) { String v = pattern.item(0);
QName typeName = type.getName() == null ? null : new QName(type.getNamespace(), type.getName()); TypeBinding binding = typeName == null ? null : schema.getType(typeName); if(binding != null) XSTypeDefinition baseTypeDef = type.getBaseType(); TypeBinding baseType = baseTypeDef == null ? null : bindType(baseTypeDef); StringList strList = type.getLexicalPattern(); if(strList != null && strList.getLength() > 0) strList = type.getLexicalEnumeration(); if(strList != null && strList.getLength() > 0) if(type.getItemType() != null) TypeBinding itemType = bindSimpleType(type.getItemType()); binding.setItemType(itemType); XSObjectList annotations = type.getAnnotations(); if(annotations != null) type.getName() + ": impl=" + classMetaData.getImpl()); type.getName() + ": unmarshalMethod=" + valueMetaData.getUnmarshalMethod() +
if(type.getItemType() != null) XSSimpleTypeDefinition itemType = type.getItemType(); if(Constants.NS_XML_SCHEMA.equals(itemType.getNamespace())) marshalled = SimpleTypeBindings.marshalList(itemType.getName(), list, null); else if(Constants.NS_XML_SCHEMA.equals(type.getNamespace())) String typeName = type.getName(); else if(type.getLexicalPattern().item(0) != null && type.derivedFrom(Constants.NS_XML_SCHEMA, Constants.QNAME_BOOLEAN.getLocalPart(), XSConstants.DERIVATION_RESTRICTION )) String item = type.getLexicalPattern().item(0); if(item.indexOf('0') != -1 && item.indexOf('1') != -1) StringList lexicalEnumeration = type.getLexicalEnumeration(); if(lexicalEnumeration != null && lexicalEnumeration.getLength() > 0) value.getClass() + " which is bound to enumeration type (" + type.getNamespace() + ", " + type.getName() + "): " + values
if (complexTypeSimplContentType.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) { XSSimpleTypeDefinition listItemType = complexTypeSimplContentType.getItemType(); if (listItemType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { final XSObjectList memberTypes = listItemType.getMemberTypes(); while (values.hasMoreTokens()) { String itemValue = values.nextToken(); XSSimpleTypeDefinition listItemTypeForUnion = getActualXDMItemTypeForSTVarietyUnion(memberTypes, itemValue); xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemTypeForUnion.getBuiltInKind(), itemValue)); xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemType.getBuiltInKind(), itemValue)); else if (complexTypeSimplContentType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSSimpleTypeDefinition simpleContentTypeForUnion = getActualXDMItemTypeForSTVarietyUnion(complexTypeSimplContentType.getMemberTypes(), value); if (simpleContentTypeForUnion.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) { setXDMTypedValueOf$valueForSTVarietyList(fRootNodeOfAssertTree, value, simpleContentTypeForUnion, ((XSSimpleTypeDefinition)simpleContentTypeForUnion.getBaseType()).getVariety() == XSSimpleTypeDefinition.VARIETY_LIST, xpath2DynamicContext);
if (Constants.NS_SCHEMA_XSD.equals(simple.getNamespace())) return createQNameFromXSSimpleType(simple); switch (simple.getVariety()) return handleSimpleType(simple.getItemType()); case XSSimpleTypeDefinition.VARIETY_UNION: XSObjectList list = simple.getMemberTypes(); if (list.getLength() > 0) return handleSimpleType((XSSimpleTypeDefinition)list.item(0)); XSTypeDefinition base = simple.getBaseType(); while (!Constants.NS_SCHEMA_XSD.equals(base.getNamespace())) base = base.getBaseType();
private void expandRelatedSimpleTypeComponents(XSSimpleTypeDefinition type, Vector componentList, String namespace, Hashtable dependencies) { final XSTypeDefinition baseType = type.getBaseType(); if (baseType != null) { addRelatedType(baseType, componentList, namespace, dependencies); } final XSTypeDefinition itemType = type.getItemType(); if (itemType != null) { addRelatedType(itemType, componentList, namespace, dependencies); } final XSTypeDefinition primitiveType = type.getPrimitiveType(); if (primitiveType != null) { addRelatedType(primitiveType, componentList, namespace, dependencies); } final XSObjectList memberTypes = type.getMemberTypes(); if (memberTypes.size() > 0) { for (int i=0; i<memberTypes.size(); i++) { addRelatedType((XSTypeDefinition)memberTypes.item(i), componentList, namespace, dependencies); } } }
if (xsSimpleType.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) XSSimpleTypeDefinition itemType = xsSimpleType.getItemType(); QName xmlBaseType = new QName(itemType.getNamespace(), itemType.getName()); javaTypeName = new LiteralTypeMapping().getJavaTypeName(xmlBaseType); if (javaTypeName != null)
XSObjectListImpl facetList = (XSObjectListImpl) simpleTypeDef.getMultiValueFacets(); if (facetList.getLength() == 0 && simpleTypeDef.getItemType() != null) { facetList = (XSObjectListImpl) simpleTypeDef.getItemType().getMultiValueFacets(); else if (simpleTypeDef.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSAssertImpl assertImpl = getFirstAssertFromUnionMemberTypes(simpleTypeDef.getMemberTypes()); if (assertImpl != null) { simpleTypeAsserts = new Vector();
if(attrType.getItemType() != null) XSSimpleTypeDefinition itemType = attrType.getItemType(); if(Constants.NS_XML_SCHEMA.equals(itemType.getNamespace())) if(Constants.QNAME_QNAME.getLocalPart().equals(itemType.getName())) attrValue = SimpleTypeBindings.marshalList(itemType.getName(), list, null); else if(attrType.getLexicalPattern().item(0) != null && attrType.derivedFrom(Constants.NS_XML_SCHEMA, Constants.QNAME_BOOLEAN.getLocalPart(), XSConstants.DERIVATION_RESTRICTION )) String item = attrType.getLexicalPattern().item(0); if(item.indexOf('0') != -1 && item.indexOf('1') != -1) else if(Constants.QNAME_QNAME.getNamespaceURI().equals(attrType.getNamespace()) && Constants.QNAME_QNAME.getLocalPart().equals(attrType.getName())) attrLocal, qName, attrDec.getTypeDefinition().getName(), attrValue.toString() ); String typeName = simpleType.getName();
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 }
void extraCheckForSTUnionAssertsAttrs(XMLAttributes attributes) { XMLAttributes attrsImpl = (XMLAttributesImpl)attributes; for (int attrIdx = 0; attrIdx < attrsImpl.getLength(); attrIdx++) { Augmentations attrAugs = attrsImpl.getAugmentations(attrIdx); AttributePSVImpl attrPsvi = (AttributePSVImpl)attrAugs.getItem(Constants.ATTRIBUTE_PSVI); XSSimpleTypeDefinition attrSimpleType = (XSSimpleTypeDefinition) attrPsvi.getTypeDefinition(); List isAssertProcessingNeededForSTUnionAttrs = fXmlSchemaValidator.getIsAssertProcessingNeededForSTUnionAttrs(); if (attrSimpleType != null && attrSimpleType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION && ((XSSimpleType) attrSimpleType.getBaseType()).getVariety() != XSSimpleTypeDefinition.VARIETY_UNION) { if (XS11TypeHelper.isAtomicStrValueValidForSTUnion(attrSimpleType.getMemberTypes(), attrsImpl.getValue(attrIdx), attrPsvi.fValue, Constants.SCHEMA_VERSION_1_1)) { isAssertProcessingNeededForSTUnionAttrs.add(Boolean.valueOf(false)); } else { isAssertProcessingNeededForSTUnionAttrs.add(Boolean.valueOf(true)); } } else { isAssertProcessingNeededForSTUnionAttrs.add(Boolean.valueOf(true)); } } } // extraCheckForSTUnionAssertsAttrs
public void setXDMTypedValueOf$valueForSTVarietyList(Element rootNodeOfAssertTree, String listStrValue, XSSimpleTypeDefinition itemType, boolean isTypeDerivedFromList, DynamicContext xpath2DynamicContext) throws Exception { if (itemType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { // itemType of xs:list has variety 'union' List xdmItemList = new ArrayList(); XSObjectList memberTypes = itemType.getMemberTypes(); // tokenize the list value by a sequence of white spaces StringTokenizer values = new StringTokenizer(listStrValue, " \n\t\r"); while (values.hasMoreTokens()) { String itemValue = values.nextToken(); XSSimpleTypeDefinition listItemTypeForUnion = getActualXDMItemTypeForSTVarietyUnion(memberTypes, itemValue); xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemTypeForUnion.getBuiltInKind(), itemValue)); } xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XS11TypeHelper.getXPath2ResultSequence(xdmItemList)); } else { setXDMTypedValueOf$value(rootNodeOfAssertTree, listStrValue, itemType, null, isTypeDerivedFromList, xpath2DynamicContext); } } // setXDMTypedValueOf$valueForSTVarietyList
if (isTypeDerivedFromList || listOrUnionType.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) { while (listStrTokens.hasMoreTokens()) { String itemValue = listStrTokens.nextToken(); if (listOrUnionType.getItemType() != null) { xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue((listOrUnionType.getItemType()).getBuiltInKind(), itemValue)); xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listOrUnionType.getBuiltInKind(), itemValue));
private void export( XMLStreamWriter writer, SimplePropertyType pt ) throws XMLStreamException { XSSimpleTypeDefinition xsdType = pt.getPrimitiveType().getXSType(); if ( xsdType == null ) { // export without XML schema information BaseType type = pt.getPrimitiveType().getBaseType(); writer.writeAttribute( "type", getSimpleType( type ) ); } else { // reconstruct XML schema type definition String name = xsdType.getName(); String ns = xsdType.getNamespace(); if ( xsdType.getName() != null ) { QName qName = new QName( ns, name ); writer.writeAttribute( "type", getPrefixedName( qName ) ); } else { // unnamed simple property writer.writeStartElement( "simpleType" ); writer.writeStartElement( "restriction" ); writer.writeAttribute( "base", getSimpleType( pt.getPrimitiveType().getBaseType() ) ); XSObjectList facets = pt.getPrimitiveType().getXSType().getFacets(); for ( int i = 0; i < facets.getLength(); i++ ) { XSFacet facet = (XSFacet) facets.item( i ); writer.writeEmptyElement( getFacetName( facet.getFacetKind() ) ); writer.writeAttribute( "value", facet.getLexicalFacetValue() ); } writer.writeEndElement(); writer.writeEndElement(); } } }
XSObject comp = (XSObject)currentComponents.get(i); if (((XSTypeDefinition)comp).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { addComponent(((XSSimpleTypeDefinition)comp).getItemType(), step.getNametest(), result); XSObject comp = (XSObject)currentComponents.get(i); if (((XSTypeDefinition)comp).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { XSObjectList memberTypes = ((XSSimpleTypeDefinition)comp).getMemberTypes(); for (int j = 0, nt = memberTypes.size(); j < nt; ++j) { addComponent((XSObject)memberTypes.get(j), step.getNametest(), result); XSObject comp = (XSObject)currentComponents.get(i); if (((XSTypeDefinition)comp).getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { addComponent(((XSSimpleTypeDefinition)comp).getPrimitiveType(), step.getNametest(), result);