Java Code Examples for com.sun.xml.xsom.XSSimpleType

The following examples show how to use com.sun.xml.xsom.XSSimpleType. These examples are extracted from open source projects. 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
private TypeDefinition loadSimpleType( XSSimpleType simpleType, boolean lazy, TypeDefinition lazyType ) {
	// processing restrictions
	TypeInlineDefinition jolietype;

	if( lazy ) {
		jolietype = (TypeInlineDefinition) lazyType;
	} else {
		if( simpleType.isRestriction() ) {
			XSRestrictionSimpleType restriction = simpleType.asRestriction();
			checkType( restriction.getBaseType() );
			jolietype =
				new TypeInlineDefinition( PARSING_CONTEXT, simpleType.getName().replace( "-", "_" ) + TYPE_SUFFIX,
					XsdUtils.xsdToNativeType( restriction.getBaseType().getName() ), Constants.RANGE_ONE_TO_ONE );

		} else {
			log( Level.WARNING, "SimpleType not processed:" + simpleType.getName() );
			jolietype = new TypeInlineDefinition( PARSING_CONTEXT, simpleType.getName().replace( "-", "_" ),
				NativeType.VOID, Constants.RANGE_ONE_TO_ONE );

		}
	}
	return jolietype;
}
 
Example 2
public Iterator<XSSimpleType> iterator() {
    return new Iterator<XSSimpleType>() {
        int idx=0;
        public boolean hasNext() {
            return idx<memberTypes.length;
        }

        public XSSimpleType next() {
            return memberTypes[idx++].getType();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
Example 3
/**
 * Creates node for attribute declaration with additional attributes.
 *
 * @param decl           Attribute declaration.
 * @param additionalAtts Additional attributes.
 */
private void dump(XSAttributeDecl decl, String additionalAtts) {
    XSSimpleType type = decl.getType();

    String str = MessageFormat.format("Attribute \"{0}\"{1}{2}{3}{4}",
            new Object[]{
                decl.getName(),
                additionalAtts,
                type.isLocal() ? "" : MessageFormat.format(
                        " type=\"'{'{0}'}'{1}\"", new Object[]{
                            type.getTargetNamespace(),
                            type.getName()}),
                decl.getFixedValue() == null ? "" : " fixed=\""
            + decl.getFixedValue() + "\"",
                decl.getDefaultValue() == null ? "" : " default=\""
            + decl.getDefaultValue() + "\""});

    SchemaTreeNode newNode = new SchemaTreeNode(str, decl.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    if (type.isLocal()) {
        simpleType(type);
    }
    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
Example 4
Source Project: jolie   Source File: SchemaWriter.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
public void listSimpleType( XSListSimpleType type ) {
    XSSimpleType itemType = type.getItemType();

    if(itemType.isLocal()) {
        println("<list>");
        indent++;
        simpleType(itemType);
        indent--;
        println("</list>");
    } else {
        // global type
        println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
            new Object[]{
                itemType.getTargetNamespace(),
                itemType.getName()
            }));
    }
}
 
Example 5
Source Project: ET_Redux   Source File: XMLSchemaProcessor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 
 * @param schemaSimpleType
 * @return
 */
public Vector<String> getSimpleTypeEnumeration ( SchemaSimpleType schemaSimpleType ) {

    Vector<String> enumeration = new Vector<String>();
    XSSimpleType st = parse( schemaSimpleType );

    XSRestrictionSimpleType restriction = st.asRestriction();

    if ( restriction != null ) {

        Iterator<? extends XSFacet> i = restriction.getDeclaredFacets().iterator();
        while (i.hasNext()) {
            XSFacet facet = i.next();

            if ( facet.getName().equals( XSFacet.FACET_ENUMERATION ) ) {
                enumeration.add( facet.getValue().value );
            }
        }
    }
    return enumeration;

}
 
Example 6
private void dump( XSAttributeDecl decl, String additionalAtts ) {
    XSSimpleType type=decl.getType();

    println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
        decl.getName(),
        additionalAtts,
        type.isLocal()?"":
            MessageFormat.format(" type=\"'{'{0}'}'{1}\"", type.getTargetNamespace(), type.getName()),
        decl.getFixedValue()==null ?
            "":" fixed=\""+decl.getFixedValue()+'\"',
        decl.getDefaultValue()==null ?
            "":" default=\""+decl.getDefaultValue()+'\"',
        type.isLocal()?"":" /"));

    if(type.isLocal()) {
        indent++;
        simpleType(type);
        indent--;
        println("</attribute>");
    }
}
 
Example 7
Source Project: citygml4j   Source File: SchemaWriter.java    License: Apache License 2.0 6 votes vote down vote up
private void dump( XSAttributeDecl decl, String additionalAtts ) {
	XSSimpleType type=decl.getType();

	println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
			decl.getName(),
			additionalAtts,
			type.isLocal()?"":
				MessageFormat.format(" type=\"'{'{0}'}'{1}\"", type.getTargetNamespace(), type.getName()),
				decl.getFixedValue()==null ?
						"":" fixed=\""+decl.getFixedValue()+'\"',
						decl.getDefaultValue()==null ?
								"":" default=\""+decl.getDefaultValue()+'\"',
								type.isLocal()?"":" /"));

	if(type.isLocal()) {
		indent++;
		simpleType(type);
		indent--;
		println("</attribute>");
	}
}
 
Example 8
Source Project: dynaform   Source File: XmlFormBuilder.java    License: Artistic License 2.0 6 votes vote down vote up
private XmlForm elementDeclSimple(XSElementDecl decl, XSSimpleType simpleType) {
  FormElement element = declSimple(simpleType, decl.getName(), decl.getDefaultValue(), decl.getFixedValue());
  if (element == null)
    return null;
  
  XmlWriter writer = new XmlElementWriter(decl.getName(), null,
      new TextXmlWriter(new FormElementWriter(element)));
  
  XmlReader reader = new XmlElementReader(decl.getName(), null,
      new TextXmlReader(new FormElementHandler(element)));
  
  if (ignoreWhitespace)
    reader = WhitespaceReader.appendTo(reader);

  return new XmlFormImpl(element, writer, reader);
}
 
Example 9
Source Project: jolie   Source File: SchemaSetImpl.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public Iterator<XSSimpleType> iterateSimpleTypes() {
    return new Iterators.Map<XSSimpleType,XSSchema>(iterateSchema()) {
        protected Iterator<XSSimpleType> apply(XSSchema u) {
            return u.iterateSimpleTypes();
        }
    };
}
 
Example 10
Source Project: jolie   Source File: NGCCRuntimeEx.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public static boolean ignorableDuplicateComponent(XSDeclaration c) {
    if(c.getTargetNamespace().equals(Const.schemaNamespace)) {
        if(c instanceof XSSimpleType)
            // hide artificial "double definitions" on simple types
            return true;
        if(c.isGlobal() && c.getName().equals("anyType"))
            return true; // ditto for anyType
    }
    return false;
}
 
Example 11
public void schema(XSSchema s) {
    // QUICK HACK: don't print the built-in components
    if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
        return;
    }

    SchemaTreeNode newNode = new SchemaTreeNode("Schema "
            + s.getLocator().getSystemId(), s.getLocator());
    this.currNode = newNode;
    this.model.addSchemaNode(newNode);

    for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
        attGroupDecl(groupDecl);
    }

    for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
        attributeDecl(attrDecl);
    }

    for (XSComplexType complexType : s.getComplexTypes().values()) {
        complexType(complexType);
    }

    for (XSElementDecl elementDecl : s.getElementDecls().values()) {
        elementDecl(elementDecl);
    }

    for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
        modelGroupDecl(modelGroupDecl);
    }

    for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
        simpleType(simpleType);
    }
}
 
Example 12
public void simpleType(XSSimpleType type) {

        String str = MessageFormat.format("Simple type {0}",
                new Object[]{type.isLocal() ? "" : " name=\""
                + type.getName() + "\""});

        SchemaTreeNode newNode = new SchemaTreeNode(str, type.getLocator());
        this.currNode.add(newNode);
        this.currNode = newNode;

        type.visit((XSSimpleTypeVisitor) this);

        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    }
 
Example 13
public void restrictionSimpleType(XSRestrictionSimpleType type) {

        if (type.getBaseType() == null) {
            // don't print anySimpleType
            if (!type.getName().equals("anySimpleType")) {
                throw new InternalError();
            }
            if (!Const.schemaNamespace.equals(type.getTargetNamespace())) {
                throw new InternalError();
            }
            return;
        }

        XSSimpleType baseType = type.getSimpleBaseType();

        String str = MessageFormat.format("Restriction {0}",
                new Object[]{baseType.isLocal() ? "" : " base=\"{"
                + baseType.getTargetNamespace() + "}"
                + baseType.getName() + "\""});

        SchemaTreeNode newNode = new SchemaTreeNode(str, baseType.getLocator());
        this.currNode.add(newNode);
        this.currNode = newNode;

        if (baseType.isLocal()) {
            simpleType(baseType);
        }

        Iterator itr = type.iterateDeclaredFacets();
        while (itr.hasNext()) {
            facet((XSFacet) itr.next());
        }

        this.currNode = (SchemaTreeNode) this.currNode.getParent();
    }
 
Example 14
Source Project: jolie   Source File: SchemaWriter.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
private void dump( XSAttributeDecl decl, String additionalAtts ) {
    XSSimpleType type=decl.getType();

    println(MessageFormat.format("<attribute name=\"{0}\"{1}{2}{3}{4}{5}>",
        new Object[]{
            decl.getName(),
            additionalAtts,
            type.isLocal()?"":
            MessageFormat.format(" type=\"'{'{0}'}'{1}\"",
            new Object[]{
                type.getTargetNamespace(),
                type.getName()
            }),
            decl.getFixedValue()==null ?
                "":" fixed=\""+decl.getFixedValue()+'\"',
            decl.getDefaultValue()==null ?
                "":" default=\""+decl.getDefaultValue()+'\"',
            type.isLocal()?"":" /"
        }));

    if(type.isLocal()) {
        indent++;
        simpleType(type);
        indent--;
        println("</attribute>");
    }
}
 
Example 15
Source Project: jolie   Source File: SchemaWriter.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void simpleType( XSSimpleType type ) {
    println(MessageFormat.format("<simpleType{0}>",
        new Object[]{
            type.isLocal()?"":" name=\""+type.getName()+'\"'
        }));
    indent++;

    type.visit((XSSimpleTypeVisitor)this);

    indent--;
    println("</simpleType>");
}
 
Example 16
Source Project: jolie   Source File: SchemaWriter.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public void restrictionSimpleType( XSRestrictionSimpleType type ) {

        if(type.getBaseType()==null) {
            // don't print anySimpleType
            if(!type.getName().equals("anySimpleType"))
                throw new InternalError();
            if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
                throw new InternalError();
            return;
        }

        XSSimpleType baseType = type.getSimpleBaseType();

        println(MessageFormat.format("<restriction{0}>",
            new Object[]{
                baseType.isLocal()?"":" base=\"{"+
                baseType.getTargetNamespace()+'}'+
                baseType.getName()+'\"'
            }));
        indent++;

        if(baseType.isLocal())
            simpleType(baseType);

        Iterator itr = type.iterateDeclaredFacets();
        while(itr.hasNext())
            facet( (XSFacet)itr.next() );

        indent--;
        println("</restriction>");
    }
 
Example 17
Source Project: jolie   Source File: Axis.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
public Iterator<XSFacet> simpleType(XSSimpleType type) {
    // TODO: it's not clear if "facets" mean all inherited facets or just declared facets
    XSRestrictionSimpleType r = type.asRestriction();
    if(r!=null)
        return r.iterateDeclaredFacets();
    else
        return empty();
}
 
Example 18
public void simpleType( XSSimpleType type ) {
      println(MessageFormat.format("<simpleType{0}>", type.isLocal()?"":" name=\""+type.getName()+'\"'));
      indent++;

      type.visit((XSSimpleTypeVisitor)this);

      indent--;
if (type.getBaseType().isLocal())
	println("</simpleType>");
  }
 
Example 19
public void listSimpleType( XSListSimpleType type ) {
    XSSimpleType itemType = type.getItemType();

    if(itemType.isLocal()) {
        println("<list>");
        indent++;
        simpleType(itemType);
        indent--;
        println("</list>");
    } else {
        // global type
        println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
            itemType.getTargetNamespace(), itemType.getName()));
    }
}
 
Example 20
public void restrictionSimpleType( XSRestrictionSimpleType type ) {

        if(type.getBaseType()==null) {
            // don't print anySimpleType
            if(!type.getName().equals("anySimpleType"))
                throw new InternalError();
            if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
                throw new InternalError();
            return;
        }

        XSSimpleType baseType = type.getSimpleBaseType();

        println(MessageFormat.format("<restriction{0}>",
            baseType.isLocal()?"":" base=\"{"+
            baseType.getTargetNamespace()+'}'+
            baseType.getName()+'\"'));
        indent++;

        if(baseType.isLocal())
            simpleType(baseType);

        Iterator<XSFacet> itr = type.iterateDeclaredFacets();
        while(itr.hasNext())
            facet( (XSFacet)itr.next() );

        indent--;
		if (baseType.isLocal())
			println("</restriction>");
    }
 
Example 21
Source Project: jaxb2-rich-contract-plugin   Source File: MetaPlugin.java    License: MIT License 5 votes vote down vote up
@Override
public QName simpleType(final XSSimpleType type) {
	if (type.getName() == null) {
		return new QName(type.getTargetNamespace(), "anonymousSimpleType");
	} else {
		return new QName(type.getTargetNamespace(), type.getName());
	}
}
 
Example 22
Source Project: citygml4j   Source File: SchemaWriter.java    License: Apache License 2.0 5 votes vote down vote up
public void schema( XSSchema s ) {

		// QUICK HACK: don't print the built-in components
		if(s.getTargetNamespace().equals(Const.schemaNamespace))
			return;

		println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
		indent++;

		Iterator<?> itr;

		itr = s.iterateAttGroupDecls();
		while(itr.hasNext())
			attGroupDecl( (XSAttGroupDecl)itr.next() );

		itr = s.iterateAttributeDecls();
		while(itr.hasNext())
			attributeDecl( (XSAttributeDecl)itr.next() );

		itr = s.iterateComplexTypes();
		while(itr.hasNext())
			complexType( (XSComplexType)itr.next() );

		itr = s.iterateElementDecls();
		while(itr.hasNext())
			elementDecl( (XSElementDecl)itr.next() );

		itr = s.iterateModelGroupDecls();
		while(itr.hasNext())
			modelGroupDecl( (XSModelGroupDecl)itr.next() );

		itr = s.iterateSimpleTypes();
		while(itr.hasNext())
			simpleType( (XSSimpleType)itr.next() );

		indent--;
		println("</schema>");
	}
 
Example 23
Source Project: citygml4j   Source File: SchemaWriter.java    License: Apache License 2.0 5 votes vote down vote up
public void simpleType( XSSimpleType type ) {
	println(MessageFormat.format("<simpleType{0}>", type.isLocal()?"":" name=\""+type.getName()+'\"'));
	indent++;

	type.visit((XSSimpleTypeVisitor)this);

	indent--;
	println("</simpleType>");
}
 
Example 24
Source Project: citygml4j   Source File: SchemaWriter.java    License: Apache License 2.0 5 votes vote down vote up
public void listSimpleType( XSListSimpleType type ) {
	XSSimpleType itemType = type.getItemType();

	if(itemType.isLocal()) {
		println("<list>");
		indent++;
		simpleType(itemType);
		indent--;
		println("</list>");
	} else {
		// global type
		println(MessageFormat.format("<list itemType=\"'{'{0}'}'{1}\" />",
				itemType.getTargetNamespace(), itemType.getName()));
	}
}
 
Example 25
Source Project: citygml4j   Source File: SchemaWriter.java    License: Apache License 2.0 5 votes vote down vote up
public void restrictionSimpleType( XSRestrictionSimpleType type ) {

		if(type.getBaseType()==null) {
			// don't print anySimpleType
			if(!type.getName().equals("anySimpleType"))
				throw new InternalError();
			if(!Const.schemaNamespace.equals(type.getTargetNamespace()))
				throw new InternalError();
			return;
		}

		XSSimpleType baseType = type.getSimpleBaseType();

		println(MessageFormat.format("<restriction{0}>",
				baseType.isLocal()?"":" base=\"{"+
						baseType.getTargetNamespace()+'}'+
						baseType.getName()+'\"'));
		indent++;

		if(baseType.isLocal())
			simpleType(baseType);

		Iterator<XSFacet> itr = type.iterateDeclaredFacets();
		while(itr.hasNext())
			facet( (XSFacet)itr.next() );

		indent--;
		println("</restriction>");
	}
 
Example 26
Source Project: dynaform   Source File: XmlFormBuilder.java    License: Artistic License 2.0 5 votes vote down vote up
private static Data createData(XSSimpleType type) {
  Data data = DataUtil.newData(type.getName());
  if (data != null)
    return data;
  
  XSSimpleType baseType = type.getSimpleBaseType();
  if (baseType == null)
    return null; // This is xs:anySimpleType
  
  if (log.isDebugEnabled())
    log.debug("Base Type: " + baseType);
  
  return createData(baseType);
}
 
Example 27
Source Project: dynaform   Source File: XmlFormBuilder.java    License: Artistic License 2.0 5 votes vote down vote up
private static Object readXmlValue(XSSimpleType type, String value) {
  Data data = createData(type);
  try {
    data.setXmlValue(value);
  } catch (Exception e) {
    log.error("Could not convert value '" + value + "'");
    return null;
  }
  return data.getValue();
}
 
Example 28
Source Project: jolie   Source File: SchemaSetImpl.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public XSSimpleType getSimpleType( String ns, String localName ) {
    XSSchema schema = getSchema(ns);
    if(schema==null)    return null;

    return schema.getSimpleType(localName);
}
 
Example 29
public XSSimpleType getPrimitiveType() {
    if(isPrimitive())       return this;
    return getSimpleBaseType().getPrimitiveType();
}
 
Example 30
Source Project: jolie   Source File: SimpleTypeImpl.java    License: GNU Lesser General Public License v2.1 4 votes vote down vote up
public XSSimpleType getRedefinedBy() {
    return redefinedBy;
}