Java Code Examples for org.apache.ws.commons.schema.XmlSchemaSimpleType#setContent()
The following examples show how to use
org.apache.ws.commons.schema.XmlSchemaSimpleType#setContent() .
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: EnumType.java From cxf with Apache License 2.0 | 6 votes |
@Override public void writeSchema(XmlSchema root) { XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true); simple.setName(getSchemaType().getLocalPart()); XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setBaseTypeName(Constants.XSD_STRING); simple.setContent(restriction); Object[] constants = getTypeClass().getEnumConstants(); List<XmlSchemaFacet> facets = restriction.getFacets(); for (Object constant : constants) { XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet(); f.setValue(getValue(constant)); facets.add(f); } }
Example 2
Source File: XmlSchemaExtractor.java From syndesis with Apache License 2.0 | 5 votes |
private void handleSimpleType(XmlSchemaSimpleType target, XmlSchemaSimpleType source) throws ParserException { // handle content final XmlSchemaSimpleTypeContent sourceContent = source.getContent(); if (sourceContent != null) { target.setContent(createXmlSchemaObjectBase(sourceContent)); } }
Example 3
Source File: XsdEmitter.java From legstar-core2 with GNU Affero General Public License v3.0 | 5 votes |
/** * Create an XML schema simple type from a restriction. * * @param restriction the XML schema restriction * @return the XML schema simple type */ protected XmlSchemaSimpleType createXmlSchemaSimpleType( final XmlSchemaSimpleTypeRestriction restriction) { XmlSchemaSimpleType xmlSchemaSimpleType = new XmlSchemaSimpleType( getXsd(), false); xmlSchemaSimpleType.setContent(restriction); return xmlSchemaSimpleType; }
Example 4
Source File: DeclaratorVisitor.java From cxf with Apache License 2.0 | 5 votes |
private XmlSchemaSimpleType duplicateXmlSchemaSimpleType(Scope newScope) { XmlSchemaSimpleType oldSimpleType = (XmlSchemaSimpleType) getSchemaType(); XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, oldSimpleType.isTopLevel()); simpleType.setContent(oldSimpleType.getContent()); simpleType.setName(newScope.toString()); return simpleType; }
Example 5
Source File: CustomStringType.java From cxf with Apache License 2.0 | 5 votes |
@Override public void writeSchema(XmlSchema root) { // this mapping gets used with xs:string, and we might get called. if (root.getTargetNamespace().equals(XMLConstants.W3C_XML_SCHEMA_NS_URI)) { return; } XmlSchemaSimpleType type = new XmlSchemaSimpleType(root, true); type.setName(getSchemaType().getLocalPart()); XmlSchemaSimpleContentExtension ext = new XmlSchemaSimpleContentExtension(); ext.setBaseTypeName(Constants.XSD_STRING); XmlSchemaSimpleTypeRestriction content = new XmlSchemaSimpleTypeRestriction(); content.setBaseTypeName(Constants.XSD_STRING); type.setContent(content); }
Example 6
Source File: ClassTest.java From cxf with Apache License 2.0 | 5 votes |
public void writeSchema(XmlSchema root) { XmlSchemaSimpleType xst = new XmlSchemaSimpleType(root, true); xst.setName("class"); XmlSchemaSimpleTypeRestriction content = new XmlSchemaSimpleTypeRestriction(); content.setBaseTypeName(Constants.XSD_STRING); xst.setContent(content); }
Example 7
Source File: ImportRepairTest.java From cxf with Apache License 2.0 | 5 votes |
private void createImportedAttributeType(XmlSchema attributeTypeSchema) { XmlSchemaSimpleType attributeImportedType = new XmlSchemaSimpleType(attributeTypeSchema, true); attributeImportedType.setName("importedAttributeType"); XmlSchemaSimpleTypeRestriction simpleContent = new XmlSchemaSimpleTypeRestriction(); attributeImportedType.setContent(simpleContent); simpleContent.setBaseTypeName(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string")); }
Example 8
Source File: EnumVisitor.java From cxf with Apache License 2.0 | 4 votes |
public void visit(AST enumNode) { // <enum_type> ::= "enum" <identifier> "{" <enumerator> {"," <enumerator>}* "}" // <enumerator> ::= <identifier> AST enumNameNode = enumNode.getFirstChild(); Scope enumNameScope = new Scope(getScope(), enumNameNode); // xmlschema:enum XmlSchemaSimpleType enumSchemaSimpleType = new XmlSchemaSimpleType(schema, true); enumSchemaSimpleType.setName(mapper.mapToQName(enumNameScope)); XmlSchemaSimpleTypeRestriction enumSchemaSimpleTypeRestriction = new XmlSchemaSimpleTypeRestriction(); enumSchemaSimpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING); //XmlSchemaSimpleTypeContent xmlSchemaSimpleTypeContent = enumSchemaSimpleTypeRestriction; enumSchemaSimpleType.setContent(enumSchemaSimpleTypeRestriction); // corba:enum Enum corbaEnum = new Enum(); corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameScope.toString())); corbaEnum.setRepositoryID(enumNameScope.toIDLRepositoryID()); corbaEnum.setType(enumSchemaSimpleType.getQName()); AST node = enumNameNode.getNextSibling(); while (node != null) { // xmlschema:enumeration XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet(); enumeration.setValue(node.toString()); enumSchemaSimpleTypeRestriction.getFacets().add(enumeration); // corba:enumerator Enumerator enumerator = new Enumerator(); enumerator.setValue(node.toString()); corbaEnum.getEnumerator().add(enumerator); node = node.getNextSibling(); } // add corbaType typeMap.getStructOrExceptionOrUnion().add(corbaEnum); // REVISIT: are there assignments needed? setSchemaType(enumSchemaSimpleType); setCorbaType(corbaEnum); }
Example 9
Source File: StringVisitor.java From cxf with Apache License 2.0 | 4 votes |
private void visitAnonBoundedString() { // xmlschema:bounded anon string XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true); simpleType.setName(stringScopedName.toString()); XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setBaseTypeName(Constants.XSD_STRING); XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet(); maxLengthFacet.setValue(boundNode.toString()); restriction.getFacets().add(maxLengthFacet); simpleType.setContent(restriction); setSchemaType(simpleType); CorbaType anon = null; if (stringNode.getType() == IDLTokenTypes.LITERAL_string) { // corba:anonstring Anonstring anonstring = new Anonstring(); anonstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString())); anonstring.setBound(Long.parseLong(boundNode.toString())); anonstring.setType(simpleType.getQName()); anon = anonstring; } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) { // corba:anonwstring Anonwstring anonwstring = new Anonwstring(); anonwstring.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString())); anonwstring.setBound(Long.parseLong(boundNode.toString())); anonwstring.setType(simpleType.getQName()); anon = anonwstring; } else { // should never get here throw new RuntimeException("StringVisitor attempted to visit an invalid node"); } // add corba:anonstring typeMap.getStructOrExceptionOrUnion().add(anon); setCorbaType(anon); }
Example 10
Source File: StringVisitor.java From cxf with Apache License 2.0 | 4 votes |
private void visitBoundedString() { // xmlschema:bounded string XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema, true); simpleType.setName(stringScopedName.toString()); XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); restriction.setBaseTypeName(Constants.XSD_STRING); XmlSchemaMaxLengthFacet maxLengthFacet = new XmlSchemaMaxLengthFacet(); maxLengthFacet.setValue(boundNode.toString()); restriction.getFacets().add(maxLengthFacet); simpleType.setContent(restriction); setSchemaType(simpleType); Scope anonstringScopedName = new Scope(getScope(), "_Anon1_" + stringScopedName.tail()); String anonstringName = anonstringScopedName.toString(); CorbaType anon = null; if (stringNode.getType() == IDLTokenTypes.LITERAL_string) { // corba:anonstring Anonstring anonstring = new Anonstring(); anonstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName)); anonstring.setBound(Long.parseLong(boundNode.toString())); anonstring.setType(simpleType.getQName()); anon = anonstring; } else if (stringNode.getType() == IDLTokenTypes.LITERAL_wstring) { // corba:anonwstring Anonwstring anonwstring = new Anonwstring(); anonwstring.setQName(new QName(typeMap.getTargetNamespace(), anonstringName)); anonwstring.setBound(Long.valueOf(boundNode.toString())); anonwstring.setType(simpleType.getQName()); anon = anonwstring; } else { // should never get here throw new RuntimeException("StringVisitor attempted to visit an invalid node"); } // add corba:anonstring typeMap.getStructOrExceptionOrUnion().add(anon); // corba:alias Alias alias = new Alias(); alias.setQName(new QName(typeMap.getTargetNamespace(), stringScopedName.toString())); alias.setBasetype(anon.getQName()); alias.setType(simpleType.getQName()); alias.setRepositoryID(stringScopedName.toIDLRepositoryID()); // add corba:alias setCorbaType(alias); }