org.apache.xerces.xs.XSElementDeclaration Java Examples
The following examples show how to use
org.apache.xerces.xs.XSElementDeclaration.
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: XmlTypeToJsonSchemaConverter.java From iaf with Apache License 2.0 | 7 votes |
public JsonStructure createJsonSchema(String elementName, XSElementDeclaration elementDecl) { JsonObjectBuilder builder = Json.createObjectBuilder(); builder.add("$schema", JSON_SCHEMA); if(elementDecl.getNamespace() != null){ builder.add("$id", elementDecl.getNamespace()); } if(schemaLocation != null){ builder.add("description", "Auto-generated by Frank!Framework based on " + schemaLocation); } if (skipRootElement) { builder.add("$ref", definitionsPath+elementName); } else { builder.add("type", "object").add("additionalProperties", false); builder.add("properties", Json.createObjectBuilder().add(elementName, Json.createObjectBuilder().add("$ref", definitionsPath+elementName).build())); } JsonObject definitionsBuilderResult = getDefinitions(); if(!definitionsBuilderResult.isEmpty()){ builder.add("definitions", definitionsBuilderResult); } return builder.build(); }
Example #2
Source File: ToXml.java From iaf with Apache License 2.0 | 6 votes |
public Set<XSElementDeclaration> findElementDeclarationsForName(String namespace, String name) { Set<XSElementDeclaration> result=new LinkedHashSet<XSElementDeclaration>(); if (schemaInformation==null) { log.warn("No SchemaInformation specified, cannot find namespaces for ["+namespace+"]:["+name+"]"); return null; } for (XSModel model:schemaInformation) { XSNamedMap components = model.getComponents(XSConstants.ELEMENT_DECLARATION); for (int i=0;i<components.getLength();i++) { XSElementDeclaration item=(XSElementDeclaration)components.item(i); if ((namespace==null || namespace.equals(item.getNamespace())) && (name==null || name.equals(item.getName()))) { if (log.isTraceEnabled()) log.trace("name ["+item.getName()+"] found in namespace ["+item.getNamespace()+"]"); result.add(item); } } } return result; }
Example #3
Source File: Json2Xml.java From iaf with Apache License 2.0 | 6 votes |
@Override public String getNodeText(XSElementDeclaration elementDeclaration, JsonValue node) { String result; if (node instanceof JsonString) { result=((JsonString)node).getString(); } else if (node instanceof JsonStructure) { // this happens when override key is present without a value result=null; } else { result=node.toString(); } if ("{}".equals(result)) { result=""; } if (log.isTraceEnabled()) log.trace("getText() node ["+ToStringBuilder.reflectionToString(node)+"] = ["+result+"]"); return result; }
Example #4
Source File: Tree2Xml.java From iaf with Apache License 2.0 | 6 votes |
@Override public final String getText(XSElementDeclaration elementDeclaration, N node) { String nodeName=elementDeclaration.getName(); Object text; if (log.isTraceEnabled()) log.trace("getText() node ["+nodeName+"] currently parsed element ["+getContext().getLocalName()+"]"); if (sp!=null && (text=sp.getOverride(getContext()))!=null) { if (log.isTraceEnabled()) log.trace("getText() node ["+nodeName+"] override found ["+text+"]"); if (text instanceof String) { return (String)text; } return text.toString(); } String result=getNodeText(elementDeclaration, node); if (sp!=null && StringUtils.isEmpty(result) && (text=sp.getDefault(getContext()))!=null) { if (log.isTraceEnabled()) log.trace("getText() node ["+nodeName+"] default found ["+text+"]"); if (text instanceof String) { result = (String)text; } result = text.toString(); } if (log.isTraceEnabled()) log.trace("getText() node ["+nodeName+"] returning value ["+result+"]"); return result; }
Example #5
Source File: SentinelXsdDumpMetadata.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
private static void dumpParticle(String path, XSParticle particle) { XSTerm term = particle.getTerm(); switch (term.getType()) { case XSConstants.ELEMENT_DECLARATION: dumpElement(path, (XSElementDeclaration) term); break; case XSConstants.MODEL_GROUP: XSModelGroup model_group = (XSModelGroup) term; final XSObjectList particles = model_group.getParticles(); for (int ipar = 0; ipar < particles.getLength(); ipar++) { dumpParticle(path, (XSParticle) particles.item(ipar)); } break; default: System.err.println(path + " - UNKNOWN"); } }
Example #6
Source File: XmlTypeToJsonSchemaConverter.java From iaf with Apache License 2.0 | 6 votes |
public JsonObject getDefinitions() { JsonObjectBuilder definitionsBuilder = Json.createObjectBuilder(); for (XSModel model:models) { XSNamedMap elements = model.getComponents(XSConstants.ELEMENT_DECLARATION); for (int i=0; i<elements.getLength(); i++) { XSElementDeclaration elementDecl = (XSElementDeclaration)elements.item(i); handleElementDeclaration(definitionsBuilder, elementDecl, false, false); } XSNamedMap types = model.getComponents(XSConstants.TYPE_DEFINITION); for (int i=0; i<types.getLength(); i++) { XSTypeDefinition typeDefinition = (XSTypeDefinition)types.item(i); String typeNamespace = typeDefinition.getNamespace(); if (typeNamespace==null || !typeDefinition.getNamespace().equals(XML_SCHEMA_NS)) { definitionsBuilder.add(typeDefinition.getName(), getDefinition(typeDefinition, false)); } } } return definitionsBuilder.build(); }
Example #7
Source File: XmlTypeToJsonSchemaConverter.java From iaf with Apache License 2.0 | 6 votes |
private void buildSkippableArrayContainer(XSParticle childParticle, JsonObjectBuilder builder){ JsonObjectBuilder refBuilder = Json.createObjectBuilder(); handleParticle(refBuilder,childParticle,null, false); XSTerm childTerm = childParticle.getTerm(); if( childTerm instanceof XSElementDeclaration ){ XSElementDeclaration elementDeclaration=(XSElementDeclaration) childTerm; XSTypeDefinition elementTypeDefinition = elementDeclaration.getTypeDefinition(); JsonStructure definition =getDefinition(elementTypeDefinition, true); builder.add("type", "array"); if (elementDeclaration.getNillable()) { definition=nillable(definition); } builder.add("items", definition); } }
Example #8
Source File: Properties2Xml.java From iaf with Apache License 2.0 | 6 votes |
@Override public Iterable<String> getChildrenByName(String node, XSElementDeclaration childElementDeclaration) throws SAXException { String name = childElementDeclaration.getName(); List<String> result=new LinkedList<String>(); if (data.containsKey(name)) { String value=data.get(name); result.addAll(Arrays.asList(value.split(valueSeparator))); if (log.isDebugEnabled()) { String elems=""; for (String elem:result) { elems+=", ["+elem+"]"; } log.debug("getChildrenByName returning: "+elems.substring(1)); } return result; } // for (int i=1;data.containsKey(name+indexSeparator+i);i++) { // result.add(data.get(name+indexSeparator+i)); // } return result; }
Example #9
Source File: CMXSDElementDeclaration.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void collectElementsDeclaration(XSTerm term, Collection<CMElementDeclaration> elements) { if (term == null) { return; } switch (term.getType()) { case XSConstants.WILDCARD: // XSWildcard wildcard = (XSWildcard) term; // ex : xsd:any document.getElements().forEach(e -> { if (!elements.contains(e)) { elements.add(e); } }); break; case XSConstants.MODEL_GROUP: XSObjectList particles = ((XSModelGroup) term).getParticles(); particles.forEach(p -> collectElementsDeclaration(((XSParticle) p).getTerm(), elements)); break; case XSConstants.ELEMENT_DECLARATION: XSElementDeclaration elementDeclaration = (XSElementDeclaration) term; document.collectElement(elementDeclaration, elements); break; } }
Example #10
Source File: XmlAligner.java From iaf with Apache License 2.0 | 6 votes |
protected void collectChildElements(XSParticle particle, Set<String> elementNames) { if (particle==null) { log.warn("collectChildElements() particle is null, is this a problem?"); return; } XSTerm term = particle.getTerm(); if (term==null) { throw new IllegalStateException("collectChildElements particle.term is null"); } if (term instanceof XSModelGroup) { XSModelGroup modelGroup = (XSModelGroup)term; XSObjectList particles = modelGroup.getParticles(); for (int i=0;i<particles.getLength();i++) { XSParticle childParticle = (XSParticle)particles.item(i); collectChildElements(childParticle, elementNames); } return; } if (term instanceof XSElementDeclaration) { XSElementDeclaration elementDeclaration=(XSElementDeclaration)term; String elementName=elementDeclaration.getName(); if (log.isTraceEnabled()) log.trace("collectChildElements() ElementDeclaration name ["+elementName+"]"); elementNames.add(elementName); } return; }
Example #11
Source File: Tree2Xml.java From iaf with Apache License 2.0 | 5 votes |
@Override protected Set<String> getUnprocessedChildElementNames(XSElementDeclaration elementDeclaration, N node, Set<String> processedChildren) throws SAXException { Set<String> unProcessedChildren = getAllNodeChildNames(elementDeclaration,node); if (unProcessedChildren!=null && !unProcessedChildren.isEmpty()) { unProcessedChildren.removeAll(processedChildren); } return unProcessedChildren; }
Example #12
Source File: XMLToJSON.java From ts-reaktive with MIT License | 5 votes |
private boolean hasAttributes(XSElementDeclaration elmt) { if (elmt.getTypeDefinition() instanceof XSComplexTypeDefinition) { //Yes, we don't need to wrap this in an object if no attributes can ever occur. But Jackson does, so we must do so too. //A future format change could do the following to make the JSON a little nicer: // XSComplexTypeDefinition def = (XSComplexTypeDefinition) elmt.getTypeDefinition(); // return def.getAttributeUses().getLength() > 0; return true; } return false; }
Example #13
Source File: DomTreeAligner.java From iaf with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getAttributes(XSElementDeclaration elementDeclaration, Node node) throws SAXException { Map<String, String> result=new HashMap<String, String>(); NamedNodeMap attributes=node.getAttributes(); if (attributes!=null) { for (int i=0;i<attributes.getLength();i++) { Node item=attributes.item(i); result.put(getNodeName(item), item.getNodeValue()); } } return result; }
Example #14
Source File: Json2Xml.java From iaf with Apache License 2.0 | 5 votes |
@Override public void handleElementContents(XSElementDeclaration elementDeclaration, JsonValue node) throws SAXException { if (node instanceof JsonObject) { JsonObject object = (JsonObject)node; if (object.containsKey(mixedContentLabel)) { JsonValue labelValue = object.get(mixedContentLabel); super.handleElementContents(elementDeclaration, labelValue); return; } } super.handleElementContents(elementDeclaration, node); }
Example #15
Source File: Json2Xml.java From iaf with Apache License 2.0 | 5 votes |
@Override public Map<String, String> getAttributes(XSElementDeclaration elementDeclaration, JsonValue node) throws SAXException { if (!readAttributes) { return null; } if (!(node instanceof JsonObject)) { if (log.isTraceEnabled()) log.trace("getAttributes() parent node is not a JsonObject, but a ["+node.getClass().getName()+"] isParentOfSingleMultipleOccurringChildElement ["+isParentOfSingleMultipleOccurringChildElement()+"] value ["+node+"], returning null"); return null; } JsonObject o = (JsonObject)node; if (o.isEmpty()) { if (log.isTraceEnabled()) log.trace("getAttributes() no children"); return null; } try { Map<String, String> result=new HashMap<String,String>(); for (String key:o.keySet()) { if (key.startsWith(attributePrefix)) { String attributeName=key.substring(attributePrefix.length()); String value=getText(elementDeclaration, o.get(key)); if (log.isTraceEnabled()) log.trace("getAttributes() attribute ["+attributeName+"] = ["+value+"]"); result.put(attributeName, value); } } return result; } catch (JsonException e) { throw new SAXException(e); } }
Example #16
Source File: CMXSDDocument.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public Collection<CMElementDeclaration> getElements() { if (elements == null) { elements = new ArrayList<>(); XSNamedMap map = model.getComponents(XSConstants.ELEMENT_DECLARATION); for (int j = 0; j < map.getLength(); j++) { XSElementDeclaration elementDeclaration = (XSElementDeclaration) map.item(j); collectElement(elementDeclaration, elements); } } return elements; }
Example #17
Source File: Json2Xml.java From iaf with Apache License 2.0 | 5 votes |
@Override public Iterable<JsonValue> getNodeChildrenByName(JsonValue node, XSElementDeclaration childElementDeclaration) throws SAXException { String name=childElementDeclaration.getName(); if (log.isTraceEnabled()) log.trace("getChildrenByName() childname ["+name+"] isParentOfSingleMultipleOccurringChildElement ["+isParentOfSingleMultipleOccurringChildElement()+"] isMultipleOccuringChildElement ["+isMultipleOccurringChildElement(name)+"] node ["+node+"]"); try { if (!(node instanceof JsonObject)) { if (log.isTraceEnabled()) log.trace("getChildrenByName() parent node is not a JsonObject, but a ["+node.getClass().getName()+"]"); return null; } JsonObject o = (JsonObject)node; if (!o.containsKey(name)) { if (log.isTraceEnabled()) log.trace("getChildrenByName() no children named ["+name+"] node ["+node+"]"); return null; } JsonValue child = o.get(name); List<JsonValue> result = new LinkedList<JsonValue>(); if (child instanceof JsonArray) { if (log.isTraceEnabled()) log.trace("getChildrenByName() child named ["+name+"] is a JsonArray, current node insertElementContainerElements ["+insertElementContainerElements+"]"); // if it could be necessary to insert elementContainers, we cannot return them as a list of individual elements now, because then the containing element would be duplicated // we also cannot use the isSingleMultipleOccurringChildElement, because it is not valid yet if (!isMultipleOccurringChildElement(name)) { if (insertElementContainerElements || !strictSyntax) { result.add(child); if (log.isTraceEnabled()) log.trace("getChildrenByName() singleMultipleOccurringChildElement ["+name+"] returning array node (insertElementContainerElements=true)"); } else { throw new SAXException(MSG_EXPECTED_SINGLE_ELEMENT+" ["+name+"]"); } } else { if (log.isTraceEnabled()) log.trace("getChildrenByName() childname ["+name+"] returning elements of array node (insertElementContainerElements=false or not singleMultipleOccurringChildElement)"); result.addAll((JsonArray)child); } return result; } result.add(child); if (log.isTraceEnabled()) log.trace("getChildrenByName() name ["+name+"] returning ["+child+"]"); return result; } catch (JsonException e) { throw new SAXException(e); } }
Example #18
Source File: Json2Xml.java From iaf with Apache License 2.0 | 5 votes |
@Override protected void processChildElement(JsonValue node, String name, XSElementDeclaration childElementDeclaration, boolean mandatory, Set<String> processedChildren) throws SAXException { String childElementName=childElementDeclaration.getName(); if (node instanceof JsonArray) { if (log.isTraceEnabled()) log.trace("Json2Xml.processChildElement() node is JsonArray, handling each of the elements as a ["+name+"]"); JsonArray ja=(JsonArray)node; for (JsonValue child:ja) { handleElement(childElementDeclaration, child); } // mark that we have processed the arrayElement containers processedChildren.add(childElementName); return; } super.processChildElement(node, name, childElementDeclaration, mandatory, processedChildren); }
Example #19
Source File: Tree2Xml.java From iaf with Apache License 2.0 | 5 votes |
@Override public boolean hasChild(XSElementDeclaration elementDeclaration, N node, String childName) throws SAXException { // should check for complex or simple type. // for complex, any path of a substitution is valid // for simple, only when a valid substitution value is found, a hit should be present. if (sp!=null && sp.hasSubstitutionsFor(getContext(), childName)) { return true; } Set<String> allChildNames=getAllNodeChildNames(elementDeclaration, node); return allChildNames!=null && allChildNames.contains(childName); }
Example #20
Source File: Tree2Xml.java From iaf with Apache License 2.0 | 5 votes |
@Override public final Iterable<N> getChildrenByName(N node, XSElementDeclaration childElementDeclaration) throws SAXException { String childName=childElementDeclaration.getName(); Iterable<N> children = getNodeChildrenByName(node, childElementDeclaration); if (children==null && sp!=null && sp.hasSubstitutionsFor(getContext(), childName)) { List<N> result=new LinkedList<N>(); result.add(node); return result; } return children; }
Example #21
Source File: ToXml.java From iaf with Apache License 2.0 | 5 votes |
public XSElementDeclaration findElementDeclarationForName(String namespace, String name) throws SAXException { Set<XSElementDeclaration> elementDeclarations=findElementDeclarationsForName(namespace, name); if (elementDeclarations==null) { log.warn("No element declarations found for ["+namespace+"]:["+name+"]"); return null; } if (elementDeclarations.size()>1) { XSElementDeclaration[] XSElementDeclarationArray=elementDeclarations.toArray(new XSElementDeclaration[0]); throw new SAXException("multiple ["+elementDeclarations.size()+"] elementDeclarations found for ["+namespace+"]:["+name+"]: first two ["+XSElementDeclarationArray[0].getNamespace()+":"+XSElementDeclarationArray[0].getName()+"]["+XSElementDeclarationArray[1].getNamespace()+":"+XSElementDeclarationArray[1].getName()+"]"); } if (elementDeclarations.size()==1) { return (XSElementDeclaration)elementDeclarations.toArray()[0]; } return null; }
Example #22
Source File: XmlTypeToJsonSchemaConverter.java From iaf with Apache License 2.0 | 5 votes |
public JsonStructure createJsonSchema(String elementName, String namespace) { XSElementDeclaration elementDecl=findElementDeclaration(elementName, namespace); if (elementDecl==null && namespace!=null) { elementDecl=findElementDeclaration(elementName, null); } if (elementDecl==null) { log.warn("Cannot find declaration for element ["+elementName+"]"); if (log.isTraceEnabled()) for (XSModel model:models) { log.trace("model ["+ToStringBuilder.reflectionToString(model,ToStringStyle.MULTI_LINE_STYLE)+"]"); } return null; } return createJsonSchema(elementName, elementDecl); }
Example #23
Source File: ToXml.java From iaf with Apache License 2.0 | 5 votes |
public String findNamespaceForName(String name) throws SAXException { XSElementDeclaration elementDeclaration=findElementDeclarationForName(null,name); if (elementDeclaration==null) { return null; } return elementDeclaration.getNamespace(); }
Example #24
Source File: ToXml.java From iaf with Apache License 2.0 | 5 votes |
protected void processChildElement(N node, String parentName, XSElementDeclaration childElementDeclaration, boolean mandatory, Set<String> processedChildren) throws SAXException { String childElementName = childElementDeclaration.getName(); if (log.isTraceEnabled()) log.trace("To2Xml.processChildElement() parent name ["+parentName+"] childElementName ["+childElementName+"]"); Iterable<N> childNodes = getChildrenByName(node,childElementDeclaration); boolean childSeen=false; if (childNodes!=null) { childSeen=true; int i=0; for (N childNode:childNodes) { i++; handleElement(childElementDeclaration,childNode); } if (log.isTraceEnabled()) log.trace("processed ["+i+"] children found by name ["+childElementName+"] in ["+parentName+"]"); if (i==0 && isDeepSearch() && childElementDeclaration.getTypeDefinition().getTypeCategory()!=XSTypeDefinition.SIMPLE_TYPE) { if (log.isTraceEnabled()) log.trace("no children processed, and deepSearch, not a simple type therefore handle node ["+childElementName+"] in ["+parentName+"]"); handleElement(childElementDeclaration,node); childSeen=true; } } else { if (log.isTraceEnabled()) log.trace("no children found by name ["+childElementName+"] in ["+parentName+"]"); if (isDeepSearch() && childElementDeclaration.getTypeDefinition().getTypeCategory()!=XSTypeDefinition.SIMPLE_TYPE) { if (log.isTraceEnabled()) log.trace("no children found, and deepSearch, not a simple type therefore handle node ["+childElementName+"] in ["+parentName+"]"); handleElement(childElementDeclaration,node); childSeen=true; } } if (childSeen) { if (processedChildren.contains(childElementName)) { throw new IllegalStateException("child element ["+childElementName+"] already processed for node ["+parentName+"]"); } processedChildren.add(childElementName); } // if (!childSeen && mandatory && isAutoInsertMandatory()) { // if (log.isDebugEnabled()) log.debug("inserting mandatory element ["+childElementName+"]"); // handleElement(childElementDeclaration,node); // insert node when minOccurs > 0, and no node is present // } }
Example #25
Source File: ToXml.java From iaf with Apache License 2.0 | 5 votes |
protected void handleSimpleTypedElement(XSElementDeclaration elementDeclaration, @SuppressWarnings("unused") XSSimpleTypeDefinition simpleTypeDefinition, N node) throws SAXException { String text = getText(elementDeclaration, node); if (log.isTraceEnabled()) log.trace("textnode name ["+elementDeclaration.getName()+"] text ["+text+"]"); if (StringUtils.isNotEmpty(text)) { sendString(text); } }
Example #26
Source File: XmlTypeToJsonSchemaConverter.java From iaf with Apache License 2.0 | 5 votes |
public void handleTerm(JsonObjectBuilder builder, XSTerm term, XSObjectList attributeUses, boolean multiOccurring, boolean forProperties) { if (term instanceof XSModelGroup) { handleModelGroup(builder, (XSModelGroup)term, attributeUses, forProperties); return; } if (term instanceof XSElementDeclaration) { XSElementDeclaration elementDeclaration = (XSElementDeclaration)term; if (elementDeclaration.getScope()==XSConstants.SCOPE_GLOBAL) { JsonObject typeDefininition = Json.createObjectBuilder().add("$ref", "#/definitions/"+elementDeclaration.getName()).build(); if (multiOccurring) { JsonObjectBuilder arrayBuilder = Json.createObjectBuilder(); arrayBuilder.add("type", "array"); arrayBuilder.add("items", typeDefininition); builder.add(elementDeclaration.getName(), arrayBuilder.build()); } else { builder.add(elementDeclaration.getName(), typeDefininition); } } else { handleElementDeclaration(builder, elementDeclaration, multiOccurring, true); } return; } if (term instanceof XSWildcard) { handleWildcard((XSWildcard)term); return; } throw new IllegalStateException("handleTerm unknown Term type ["+term.getClass().getName()+"]"); }
Example #27
Source File: XmlTypeToJsonSchemaConverter.java From iaf with Apache License 2.0 | 5 votes |
private void handleElementDeclaration(JsonObjectBuilder builder, XSElementDeclaration elementDeclaration, boolean multiOccurring, boolean shouldCreateReferences){ String elementName=elementDeclaration.getName(); //if (log.isTraceEnabled()) log.trace("XSElementDeclaration name ["+elementName+"]"); if (log.isTraceEnabled()) log.trace("XSElementDeclaration element ["+elementName+"]["+ToStringBuilder.reflectionToString(elementDeclaration,ToStringStyle.MULTI_LINE_STYLE)+"]"); XSTypeDefinition elementTypeDefinition = elementDeclaration.getTypeDefinition(); JsonStructure definition; if (elementTypeDefinition.getAnonymous() || XML_SCHEMA_NS.equals(elementTypeDefinition.getNamespace())) { definition =getDefinition(elementTypeDefinition, shouldCreateReferences); } else { definition = Json.createObjectBuilder().add("$ref",definitionsPath+elementTypeDefinition.getName()).build(); } if (elementDeclaration.getNillable()) { definition=nillable(definition); } if (multiOccurring) { JsonObjectBuilder arrayBuilder = Json.createObjectBuilder(); arrayBuilder.add("type", "array"); arrayBuilder.add("items", definition); builder.add(elementName, arrayBuilder.build()); } else { if (definition!=null) { builder.add(elementName, definition); } } }
Example #28
Source File: ToXml.java From iaf with Apache License 2.0 | 5 votes |
public void handleElementContents(XSElementDeclaration elementDeclaration, N node) throws SAXException { XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition(); if (typeDefinition==null) { log.warn("handleElementContents typeDefinition is null"); handleSimpleTypedElement(elementDeclaration, null, node); return; } switch (typeDefinition.getTypeCategory()) { case XSTypeDefinition.SIMPLE_TYPE: if (log.isTraceEnabled()) log.trace("handleElementContents typeDefinition.typeCategory is SimpleType, no child elements"); handleSimpleTypedElement(elementDeclaration, (XSSimpleTypeDefinition)typeDefinition, node); return; case XSTypeDefinition.COMPLEX_TYPE: XSComplexTypeDefinition complexTypeDefinition=(XSComplexTypeDefinition)typeDefinition; switch (complexTypeDefinition.getContentType()) { case XSComplexTypeDefinition.CONTENTTYPE_EMPTY: if (log.isTraceEnabled()) log.trace("handleElementContents complexTypeDefinition.contentType is Empty, no child elements"); return; case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE: if (log.isTraceEnabled()) log.trace("handleElementContents complexTypeDefinition.contentType is Simple, no child elements (only characters)"); handleSimpleTypedElement(elementDeclaration, null, node); return; case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: case XSComplexTypeDefinition.CONTENTTYPE_MIXED: handleComplexTypedElement(elementDeclaration,node); return; default: throw new IllegalStateException("handleElementContents complexTypeDefinition.contentType is not Empty,Simple,Element or Mixed, but ["+complexTypeDefinition.getContentType()+"]"); } default: throw new IllegalStateException("handleElementContents typeDefinition.typeCategory is not SimpleType or ComplexType, but ["+typeDefinition.getTypeCategory()+"] class ["+typeDefinition.getClass().getName()+"]"); } }
Example #29
Source File: ToXml.java From iaf with Apache License 2.0 | 5 votes |
/** * Pushes node through validator. * * Must push all nodes through validatorhandler, recursively, respecting the alignment request. * Must set current=node before calling validatorHandler.startElement(), in order to get the right argument for the onStartElement / performAlignment callbacks. */ public void handleNode(C container, String name, String nodeNamespace) throws SAXException { if (log.isTraceEnabled()) log.trace("handleNode() name ["+name+"] namespace ["+nodeNamespace+"]"); N rootNode=getRootNode(container); if (StringUtils.isEmpty(nodeNamespace)) { nodeNamespace=getNodeNamespaceURI(rootNode); } XSElementDeclaration elementDeclaration=findElementDeclarationForName(nodeNamespace,name); if (elementDeclaration==null) { throw new SAXException(MSG_CANNOT_NOT_FIND_ELEMENT_DECLARATION+" for ["+name+"] in namespace ["+nodeNamespace+"]"); // if (log.isTraceEnabled()) log.trace("node ["+name+"] did not find elementDeclaration, assigning targetNamespace ["+getTargetNamespace()+"]"); // nodeNamespace=getTargetNamespace(); } handleElement(elementDeclaration,rootNode); }
Example #30
Source File: XmlAligner.java From iaf with Apache License 2.0 | 5 votes |
public XSTypeDefinition getTypeDefinition(PSVIProvider psviProvider) { ElementPSVI elementPSVI = psviProvider.getElementPSVI(); if (log.isTraceEnabled()) log.trace("getTypeDefinition() elementPSVI ["+ToStringBuilder.reflectionToString(elementPSVI)+"]"); XSElementDeclaration elementDeclaration = elementPSVI.getElementDeclaration(); if (log.isTraceEnabled()) log.trace("getTypeDefinition() elementPSVI element declaration ["+ToStringBuilder.reflectionToString(elementDeclaration)+"]"); if (elementDeclaration==null) { return null; } XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition(); if (log.isTraceEnabled()) log.trace("getTypeDefinition() elementDeclaration typeDefinition ["+ToStringBuilder.reflectionToString(typeDefinition)+"]"); return typeDefinition; }