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);
}
}