本文整理汇总了Java中org.apache.xerces.xs.XSElementDeclaration.getName方法的典型用法代码示例。如果您正苦于以下问题:Java XSElementDeclaration.getName方法的具体用法?Java XSElementDeclaration.getName怎么用?Java XSElementDeclaration.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xs.XSElementDeclaration
的用法示例。
在下文中一共展示了XSElementDeclaration.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findReference
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
/**
* Finds all the element and complexType references for the specified root element and populates a map entry with
* element names referenced by the element.
*
* @param elementDeclaration XSElementDeclaration : the root element
*/
private void findReference(XSElementDeclaration elementDeclaration) {
String elemName = elementDeclaration.getName();
String thisContext = elemName;
XSTypeDefinition typeDefinition = elementDeclaration.getTypeDefinition();
if (null != typeDefinition) {
String typeDefName = typeDefinition.getName();
currentNodeNames.clear();
currentNodeNames.add(elementDeclaration.getName());
if (typeDefinition instanceof XSComplexTypeDefinition) {
addToSchemaMap(elemName, typeDefName);
if (null != typeDefName) {
thisContext = typeDefName;
}
XSParticle particle = ((XSComplexTypeDefinition) typeDefinition).getParticle();
findReferenceInParticle(thisContext, particle);
}
else {
addToSchemaMap(elemName, typeDefName);
if (null != typeDefName) {
thisContext = typeDefName;
}
}
}
}
示例2: parseXbrlTaxonomy
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
private XbrlTaxonomy parseXbrlTaxonomy(XSElementDeclaration elementDec) throws XbrlException{
//should only contain the synthetic annotation for the attributes
XSObjectList list = elementDec.getAnnotations();
if(list.getLength() != 1)
throw new XbrlException("element with ns: " + elementDec.getNamespace() + " name: " + elementDec.getName() + " has unexpected number of annotations:" + list.getLength());
try{
XSAnnotation attributeObj = (XSAnnotation)list.item(0);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.newDocument();
attributeObj.writeAnnotation(doc, XSAnnotation.W3C_DOM_DOCUMENT);
NamedNodeMap attributes = doc.getFirstChild().getAttributes();
XbrlTaxonomy xbrlTaxonomy = new XbrlTaxonomy(elementDec, attributes);
return xbrlTaxonomy;
}
catch(Exception e){
}
return null;
}
示例3: getChildrenByName
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
@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;
}
示例4: collectChildElements
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
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 (DEBUG) log.debug("collectChildElements() ElementDeclaration name ["+elementName+"]");
elementNames.add(elementName);
}
return;
}
示例5: XbrlTaxonomy
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
public XbrlTaxonomy(XSElementDeclaration elementDec, NamedNodeMap attributes){
this.namespace = elementDec.getNamespace();
this.name = elementDec.getName();
this.isAbstract = elementDec.getAbstract();
this.isNillable = elementDec.getNillable();
//this.type = elementDec.getTypeDefinition();
this.substitutionGroupNamespace = elementDec.getSubstitutionGroupAffiliation().getNamespace();
this.substitutionGroupName = elementDec.getSubstitutionGroupAffiliation().getName();
this.typeNamespace = elementDec.getTypeDefinition().getNamespace();
this.typeName = elementDec.getTypeDefinition().getName();
//this.substitutionGroup = elementDec.getSubstitutionGroupAffiliation();
//this.hasBalanceType = false;
//this.hasPeriodType = false;
for(int i = 0; i < attributes.getLength(); i++){
Node attrNode = attributes.item(i);
//String attrNS = attrNode.getNamespaceURI();
String attrName = attrNode.getNodeName().toLowerCase();
String attrValue = attrNode.getNodeValue();
if(attrName.equals("xbrli:periodtype")){
//this.hasPeriodType = true;
periodType = PeriodType.valueOf(attrValue.toLowerCase());
}
else if(attrName.equals("xbrli:balance")){
//this.hasBalanceType = true;
balanceType = BalanceType.valueOf(attrValue.toLowerCase());
}
}
}
示例6: isElementMultiValued
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
/**
* Is it possible for this element to occur more than once within its
* enclosing type?
* @param xiElement
* @return
*/
private static boolean isElementMultiValued(XSElementDeclaration xiDecl)
{
boolean lmulti;
XSComplexTypeDefinition lComplex = xiDecl.getEnclosingCTDefinition();
if (lComplex == null)
{
lmulti = false;
}
else
{
XSParticle lTopParticle = lComplex.getParticle();
Boolean lResult = isElementMultiWithin(xiDecl, false, lTopParticle);
if (lResult == null)
{
throw new RuntimeException("Couldn't find declaration of " + xiDecl.getName() + " within " + lComplex.getName());
}
lmulti = lResult;
}
return lmulti;
}
示例7: getNodeChildrenByName
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
@Override
public Iterable<Node> getNodeChildrenByName(Node node, XSElementDeclaration childElementDeclaration) throws SAXException {
String name=childElementDeclaration.getName();
if (DEBUG) log.debug("getChildrenByName() node ["+node+"] name ["+name+"]");
List<Node> children = new LinkedList<Node>();
for (Node cur=node.getFirstChild();cur!=null;cur=cur.getNextSibling()) {
if (cur.getNodeType()==Node.ELEMENT_NODE && name.equals(getNodeName(cur))) {
if (DEBUG) log.debug("getChildrenByName() node ["+node+"] added node ["+getNodeName(cur)+"]");
children.add(cur);
}
}
return children;
}
示例8: getNodeChildrenByName
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
@Override
public Iterable<JsonValue> getNodeChildrenByName(JsonValue node, XSElementDeclaration childElementDeclaration) throws SAXException {
String name=childElementDeclaration.getName();
if (DEBUG) log.debug("getChildrenByName() childname ["+name+"] isParentOfSingleMultipleOccurringChildElement ["+isParentOfSingleMultipleOccurringChildElement()+"] isMultipleOccuringChildElement ["+isMultipleOccurringChildElement(name)+"] node ["+node+"]");
try {
if (!(node instanceof JsonObject)) {
if (DEBUG) log.debug("getChildrenByName() parent node is not a JsonObject, but a ["+node.getClass().getName()+"]");
return null;
}
JsonObject o = (JsonObject)node;
if (!o.containsKey(name)) {
if (DEBUG) log.debug("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 (DEBUG) log.debug("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 (DEBUG) log.debug("getChildrenByName() singleMultipleOccurringChildElement ["+name+"] returning array node (insertElementContainerElements=true)");
} else {
throw new SAXException(MSG_EXPECTED_SINGLE_ELEMENT+" ["+name+"]");
}
} else {
if (DEBUG) log.debug("getChildrenByName() childname ["+name+"] returning elements of array node (insertElementContainerElements=false or not singleMultipleOccurringChildElement)");
result.addAll((JsonArray)child);
}
return result;
}
result.add(child);
if (DEBUG) log.debug("getChildrenByName() name ["+name+"] returning ["+child+"]");
return result;
} catch (JsonException e) {
throw new SAXException(e);
}
}
示例9: processChildElement
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
@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 (DEBUG) log.debug("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);
}
示例10: getChildrenByName
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
@Override
public final Iterable<N> getChildrenByName(N node, XSElementDeclaration childElementDeclaration) throws SAXException {
String childName=childElementDeclaration.getName();
if (overrideValues!=null && overrideValues.containsKey(childName)) {
List<N> result=new LinkedList<N>();
result.add(node);
return result;
}
return getNodeChildrenByName(node, childElementDeclaration);
}
示例11: processChildElement
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
protected void processChildElement(N node, String parentName, XSElementDeclaration childElementDeclaration, boolean mandatory, Set<String> processedChildren) throws SAXException {
String childElementName = childElementDeclaration.getName();
if (DEBUG) log.debug("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 (DEBUG) log.debug("processed ["+i+"] children found by name ["+childElementName+"] in ["+parentName+"]");
if (i==0 && isDeepSearch()) {
handleElement(childElementDeclaration,node);
}
} else {
if (DEBUG) log.debug("no children found by name ["+childElementName+"] in ["+parentName+"]");
}
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
}
}
示例12: dumpElement
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
private static void dumpElement(String path, XSElementDeclaration element)
{
String output_path = "" + path + "/" + element.getName();
XSTypeDefinition type = element.getTypeDefinition();
if (type.getName().endsWith("Array"))
{
// System.err.println(element.getName() + " - " + type.getName()
// + " SKIPPED !");
return;
}
if (((type.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE)
|| ((XSComplexTypeDefinition) type)
.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE))
{
if (includesBaseType(type, "string")
|| includesBaseType(type, "integer")
|| includesBaseType(type, "boolean"))
{
// System.out.println(" <metadata name=\"" +
// element.getName() + "\" type=\"text/plain\" category=\"\">");
// System.out.println(" " +
// indexedName(element.getName())
// + " { local:values($doc" + output_path + ") }");
// System.out.println(" </metadata>,");
System.out.println(" local:getMetadata('" +
element.getName() + "', '" +
indexedName(element.getName()) + "',");
System.out.println(" $doc" + output_path + "),");
}
}
else
{
dumpParticle(output_path,
((XSComplexTypeDefinition)type).getParticle());
}
}
示例13: processElement
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
private Path processElement(Path parent, String path, XSElementDeclaration xsElement,
Map<String, List<XSElementDeclaration>> substitutions,
List<XSElementDeclaration> parents, int minOccurs, int maxOccurs) throws BagriException {
Path element = parent;
if (!xsElement.getAbstract()) {
path += xsElement.getNamespace() == null ? "/" + xsElement.getName() : "/{" + xsElement.getNamespace() + "}" + xsElement.getName();
element = modelMgr.translatePath(parent.getRoot(), path, NodeKind.element, parent.getPathId(), XQItemType.XQBASETYPE_ANYTYPE,
Occurrence.getOccurrence(minOccurs, maxOccurs));
logger.trace("processElement; element: {}; type: {}; got XDMPath: {}", path, xsElement.getTypeDefinition(), element);
}
List<XSElementDeclaration> subs = substitutions.get(xsElement.getName());
logger.trace("processElement; got {} substitutions for element: {}", subs == null ? 0 : subs.size(), xsElement.getName());
if (subs != null) {
for (XSElementDeclaration sub: subs) {
processElement(parent, path, sub, substitutions, parents, minOccurs, maxOccurs);
}
}
if (parents.contains(xsElement)) {
return element;
}
parents.add(xsElement);
Path text = null;
if (xsElement.getTypeDefinition().getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
XSComplexTypeDefinition ctd = (XSComplexTypeDefinition) xsElement.getTypeDefinition();
// TODO: process derivations..?
// element's attributes
XSObjectList xsAttrList = ctd.getAttributeUses();
for (int i = 0; i < xsAttrList.getLength(); i ++) {
processAttribute(element, path, (XSAttributeUse) xsAttrList.item(i));
}
element = processParticle(element, path, ctd.getParticle(), substitutions, parents);
if (ctd.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE ||
ctd.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED) {
path += "/text()";
text = modelMgr.translatePath(element.getRoot(), path, NodeKind.text, element.getPathId(), getBaseType(ctd.getSimpleType()),
Occurrence.getOccurrence(minOccurs, maxOccurs));
logger.trace("processElement; complex text: {}; type: {}; got XDMPath: {}", path, ctd.getBaseType(), text);
}
} else { //if (xsElementDecl.getTypeDefinition().getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
XSSimpleTypeDefinition std = (XSSimpleTypeDefinition) xsElement.getTypeDefinition();
path += "/text()";
text = modelMgr.translatePath(element.getRoot(), path, NodeKind.text, element.getPathId(), getBaseType(std),
Occurrence.getOccurrence(minOccurs, maxOccurs));
logger.trace("processElement; simple text: {}; type: {}; got XDMPath: {}", path, std, text);
}
if (text != null) {
element.setPostId(text.getPathId());
modelMgr.updatePath(element);
}
if (parent.getPostId() < element.getPostId()) {
parent.setPostId(element.getPostId());
modelMgr.updatePath(parent);
}
parents.remove(xsElement);
return element;
}
示例14: isElementMultiWithin
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
/**
* Test if the given element may appear multipe times within the given
* particle.
*
* @param xiDecl the declaration to search for
* @param xiMulti does the particle itself already occur multiple times?
* @param xiParticle the particle to search within
* @return true if it may appear multiple times, false if it may appear at
* most once, null if the element is not found within the particle.
*/
private static Boolean isElementMultiWithin(XSElementDeclaration xiDecl,
boolean xiMulti,
XSParticle xiParticle)
{
if (xiParticle == null)
{
return null;
}
// Determine context multiplicity: either we're already multiple, or this
// particle can appear multiple times.
boolean lOuter =
xiMulti ||
xiParticle.getMaxOccursUnbounded() ||
(xiParticle.getMaxOccurs() > 1);
Boolean lMulti;
XSTerm lTerm = xiParticle.getTerm();
if (lTerm instanceof XSModelGroup)
{
XSModelGroup lGroup = (XSModelGroup)lTerm;
XSObjectList lParticles = ((XSModelGroup)lTerm).getParticles();
lMulti = null;
for (Object lParticleObj : lParticles)
{
XSParticle lParticle = (XSParticle)lParticleObj;
Boolean lSub = isElementMultiWithin(xiDecl, lOuter, lParticle);
if (lSub != null)
{
if (lMulti == null)
{
// Normal case: we've found a single match
lMulti = lSub;
}
else
{
// Multiple matches for the element - that's not very sane
// (although we could just do lMulti = true).
throw new RuntimeException("Multiple separate occurrences of the same element: " + xiDecl.getName());
}
}
}
}
else if (lTerm instanceof XSElementDeclaration)
{
XSElementDeclaration lElementDecl = (XSElementDeclaration)lTerm;
if (isEqualName(lElementDecl, xiDecl))
{
// We have a match! Take the multiplicity we've determined for this
// context.
lMulti = lOuter;
}
else
{
lMulti = null;
}
}
else
{
throw new RuntimeException("Wildcard or other particle (complex type component) not supported: " + xiDecl.getName());
}
return lMulti;
}
示例15: handleElement
import org.apache.xerces.xs.XSElementDeclaration; //导入方法依赖的package包/类
public void handleElement(XSElementDeclaration elementDeclaration, N node) throws SAXException {
String name = elementDeclaration.getName();
String elementNamespace=elementDeclaration.getNamespace();
String qname=getQName(elementNamespace, name);
if (DEBUG) log.debug("handleNode() name ["+name+"] elementNamespace ["+elementNamespace+"]");
newLine();
AttributesImpl attributes=new AttributesImpl();
Map<String,String> nodeAttributes = getAttributes(elementDeclaration, node);
if (DEBUG) log.debug("node ["+name+"] search for attributeDeclaration");
XSTypeDefinition typeDefinition=elementDeclaration.getTypeDefinition();
XSObjectList attributeUses=getAttributeUses(typeDefinition);
if (attributeUses==null || attributeUses.getLength()==0) {
if (nodeAttributes!=null && nodeAttributes.size()>0) {
log.warn("node ["+name+"] found ["+nodeAttributes.size()+"] attributes, but no declared AttributeUses");
} else {
if (DEBUG) log.debug("node ["+name+"] no attributeUses, no attributes");
}
} else {
if (nodeAttributes==null || nodeAttributes.isEmpty()) {
log.warn("node ["+name+"] declared ["+attributeUses.getLength()+"] attributes, but no attributes found");
} else {
for (int i=0;i<attributeUses.getLength(); i++) {
XSAttributeUse attributeUse=(XSAttributeUse)attributeUses.item(i);
//if (DEBUG) log.debug("startElement ["+localName+"] attributeUse ["+ToStringBuilder.reflectionToString(attributeUse)+"]");
XSAttributeDeclaration attributeDeclaration=attributeUse.getAttrDeclaration();
if (DEBUG) log.debug("node ["+name+"] attributeDeclaration ["+ToStringBuilder.reflectionToString(attributeDeclaration)+"]");
XSSimpleTypeDefinition attTypeDefinition=attributeDeclaration.getTypeDefinition();
if (DEBUG) log.debug("node ["+name+"] attTypeDefinition ["+ToStringBuilder.reflectionToString(attTypeDefinition)+"]");
String attName=attributeDeclaration.getName();
if (nodeAttributes.containsKey(attName)) {
String value=nodeAttributes.remove(attName);
String uri=attributeDeclaration.getNamespace();
String attqname=getQName(uri,attName);
String type=null;
if (DEBUG) log.debug("node ["+name+"] adding attribute ["+attName+"] value ["+value+"]");
attributes.addAttribute(uri, attName, attqname, type, value);
}
}
}
}
if (isNil(elementDeclaration, node)) {
validatorHandler.startPrefixMapping(XSI_PREFIX_MAPPING, XML_SCHEMA_INSTANCE_NAMESPACE);
attributes.addAttribute(XML_SCHEMA_INSTANCE_NAMESPACE, XML_SCHEMA_NIL_ATTRIBUTE, XSI_PREFIX_MAPPING+":"+XML_SCHEMA_NIL_ATTRIBUTE, "xs:boolean", "true");
validatorHandler.startElement(elementNamespace, name, qname, attributes);
validatorHandler.endElement(elementNamespace, name, qname);
validatorHandler.endPrefixMapping(XSI_PREFIX_MAPPING);
} else {
validatorHandler.startElement(elementNamespace, name, qname, attributes);
handleElementContents(elementDeclaration, node);
validatorHandler.endElement(elementNamespace, name, qname);
}
// if (createdPrefix!=null) {
// validatorHandler.endPrefixMapping(createdPrefix);
// }
}