getparent java_Java Element.getParent方法代码示例

import org.dom4j.Element; //导入方法依赖的package包/类

/**

* Process an exention element of a DerivedContent model. For extensions (used

* in Simple and ComplexContent type definitions, we create a dummy element of

* the extension's base type. The dummy element has an attribute of

* "extension" so it can be identified and handled properly when it is fed

* back into processSchemaElement and expanded as if it were an element of the

* baseType.

*

* Finaly the attributes (if any) are processed as if they were defined in the

* parent of the parent element, which is the enclosing ComplexType.

*

* @param e The schema extention element being processed

* @param parent The instanceDoc parent of the extention (a simple or

* complexContent element)

* @exception Exception NOT YET DOCUMENTED

*/

private void processExtension(Element e, Element parent) throws Exception {

String baseType = e.attributeValue("base");

String parentName = XPathUtils.getNodeName(getPath(parent));

prtln("\n processExtension() handling extension (baseType: " + baseType + ")", 1);

prtln(pp(e));

// create dummy element

// embed namespace information into the dummy element so it is available to "isBuiltInType"

QName qname = df.createQName("element", e.getNamespace());

Element extElement = df.createElement(qname);

extElement.addAttribute("type", baseType);

extElement.addAttribute("extension", "true");

extElement.addAttribute("name", parentName);

prtln("\t ... extn element: " + extElement.asXML() + "\n", 1);

/*

* // print out some DEBUGGING info

* if (parentName.equals("catalog")) {

* prtln("parent name = " + parentName, 1);

* prtln("base = " + baseType, 1);

* prtln("dummy extension element: " + extElement.asXML(), 1);

* }

*/

// this (or something like it must be here to catch the extension attributes?

processSchemaElement(extElement, parent);

// take care of the attributes of this extention

for (Iterator i = e.elementIterator(); i.hasNext(); ) {

Element grandParent = parent.getParent();

Element childAttribute = (Element) i.next();

processSchemaElement(childAttribute, parent);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值