本文整理汇总了Java中org.apache.xerces.util.DOMUtil类的典型用法代码示例。如果您正苦于以下问题:Java DOMUtil类的具体用法?Java DOMUtil怎么用?Java DOMUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DOMUtil类属于org.apache.xerces.util包,在下文中一共展示了DOMUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
/**
* Initialize Subcollection from dom element
*
* @param collection
*/
public void initialize(Element collection) {
this.id = DOMUtil.getChildText(
collection.getElementsByTagName(TAG_ID).item(0)).trim();
this.name = DOMUtil.getChildText(
collection.getElementsByTagName(TAG_NAME).item(0)).trim();
this.wlString = DOMUtil.getChildText(
collection.getElementsByTagName(TAG_WHITELIST).item(0)).trim();
parseList(this.whiteList, wlString);
// Check if there's a blacklist we need to parse
NodeList nodeList = collection.getElementsByTagName(TAG_BLACKLIST);
if (nodeList.getLength() > 0) {
this.blString = DOMUtil.getChildText(nodeList.item(0)).trim();
parseList(this.blackList, blString);
}
// Check if there's a key element or set default name
nodeList = collection.getElementsByTagName(TAG_KEY);
if (nodeList.getLength() == 1) {
this.key = DOMUtil.getChildText(nodeList.item(0)).trim();
}
}
示例2: element2Locator
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
/**
* Extract location information from an Element node, store such
* information in the passed-in SimpleLocator object, then return
* true. Returning false means can't extract or store such information.
*/
public boolean element2Locator(Element e, SimpleLocator l) {
if (l == null)
return false;
if (e instanceof ElementImpl) {
ElementImpl ele = (ElementImpl)e;
// get system id from document object
Document doc = ele.getOwnerDocument();
String sid = (String)fDoc2SystemId.get(DOMUtil.getRoot(doc));
// line/column numbers are stored in the element node
int line = ele.getLineNumber();
int column = ele.getColumnNumber();
l.setValues(sid, sid, line, column, ele.getCharacterOffset());
return true;
}
return false;
}
示例3: resolveNamespace
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
public void resolveNamespace(Element element, Attr[] attrs,
SchemaNamespaceSupport nsSupport) {
// push the namespace context
nsSupport.pushContext();
// search for new namespace bindings
int length = attrs.length;
Attr sattr = null;
String rawname, prefix, uri;
for (int i = 0; i < length; i++) {
sattr = attrs[i];
rawname = DOMUtil.getName(sattr);
prefix = null;
if (rawname.equals(XMLSymbols.PREFIX_XMLNS))
prefix = XMLSymbols.EMPTY_STRING;
else if (rawname.startsWith("xmlns:"))
prefix = fSymbolTable.addSymbol(DOMUtil.getLocalName(sattr));
if (prefix != null) {
uri = fSymbolTable.addSymbol(DOMUtil.getValue(sattr));
nsSupport.declarePrefix(prefix, uri.length()!=0 ? uri : null);
}
}
}
示例4: processPSVIAnnotation
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
private void processPSVIAnnotation(XSAnnotation ann) {
if (ann == null) {
sendElementEvent("psv:annotation");
}
else {
sendIndentedElement("psv:annotation");
// We can't get all the information from DOM, but I've outputed what
// we can get -- PJM
Node dom = new DocumentImpl();
ann.writeAnnotation(dom, XSAnnotation.W3C_DOM_DOCUMENT);
// this child will be the annotation element
Element annot = DOMUtil.getFirstChildElement(dom);
processDOMElement(
annot,
SchemaSymbols.ELT_APPINFO,
"psv:applicationInformation");
processDOMElement(
annot,
SchemaSymbols.ELT_DOCUMENTATION,
"psv:userInformation");
processDOMAttributes(annot);
sendUnIndentedElement("psv:annotation");
}
}
示例5: genAnonTypeName
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
private String genAnonTypeName(Element simpleTypeDecl) {
// Generate a unique name for the anonymous type by concatenating together the
// names of parent nodes
// The name is quite good for debugging/error purposes, but we may want to
// revisit how this is done for performance reasons (LM).
StringBuffer typeName = new StringBuffer("#AnonType_");
Element node = DOMUtil.getParent(simpleTypeDecl);
while (node != null && (node != DOMUtil.getRoot(DOMUtil.getDocument(node)))) {
typeName.append(node.getAttribute(SchemaSymbols.ATT_NAME));
node = DOMUtil.getParent(node);
}
return typeName.toString();
}
示例6: resolveKeyRefs
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
protected void resolveKeyRefs() {
for (int i=0; i<fKeyrefStackPos; i++) {
XSDocumentInfo keyrefSchemaDoc = fKeyrefsMapXSDocumentInfo[i];
keyrefSchemaDoc.fNamespaceSupport.makeGlobal();
keyrefSchemaDoc.fNamespaceSupport.setEffectiveContext( fKeyrefNamespaceContext[i] );
SchemaGrammar keyrefGrammar = fGrammarBucket.getGrammar(keyrefSchemaDoc.fTargetNamespace);
// need to set <keyref> to hidden before traversing it,
// because it has global scope
DOMUtil.setHidden(fKeyrefs[i], fHiddenNodes);
fKeyrefTraverser.traverse(fKeyrefs[i], fKeyrefElems[i], keyrefSchemaDoc, keyrefGrammar);
}
}
示例7: storeKeyRef
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
protected void storeKeyRef (Element keyrefToStore, XSDocumentInfo schemaDoc,
XSElementDecl currElemDecl) {
String keyrefName = DOMUtil.getAttrValue(keyrefToStore, SchemaSymbols.ATT_NAME);
if (keyrefName.length() != 0) {
String keyrefQName = schemaDoc.fTargetNamespace == null?
"," + keyrefName: schemaDoc.fTargetNamespace+","+keyrefName;
checkForDuplicateNames(keyrefQName, IDENTITYCONSTRAINT_TYPE, fUnparsedIdentityConstraintRegistry, fUnparsedIdentityConstraintRegistrySub, keyrefToStore, schemaDoc);
}
// now set up all the registries we'll need...
// check array sizes
if (fKeyrefStackPos == fKeyrefs.length) {
Element [] elemArray = new Element [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
System.arraycopy(fKeyrefs, 0, elemArray, 0, fKeyrefStackPos);
fKeyrefs = elemArray;
XSElementDecl [] declArray = new XSElementDecl [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
System.arraycopy(fKeyrefElems, 0, declArray, 0, fKeyrefStackPos);
fKeyrefElems = declArray;
String[][] stringArray = new String [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT][];
System.arraycopy(fKeyrefNamespaceContext, 0, stringArray, 0, fKeyrefStackPos);
fKeyrefNamespaceContext = stringArray;
XSDocumentInfo [] xsDocumentInfo = new XSDocumentInfo [fKeyrefStackPos + INC_KEYREF_STACK_AMOUNT];
System.arraycopy(fKeyrefsMapXSDocumentInfo, 0, xsDocumentInfo, 0, fKeyrefStackPos);
fKeyrefsMapXSDocumentInfo = xsDocumentInfo;
}
fKeyrefs[fKeyrefStackPos] = keyrefToStore;
fKeyrefElems[fKeyrefStackPos] = currElemDecl;
fKeyrefNamespaceContext[fKeyrefStackPos] = schemaDoc.fNamespaceSupport.getEffectiveLocalContext();
fKeyrefsMapXSDocumentInfo[fKeyrefStackPos++] = schemaDoc;
}
示例8: changeRedefineGroup
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
private int changeRedefineGroup(String originalQName, String elementSought,
String newName, Element curr, XSDocumentInfo schemaDoc) {
int result = 0;
for (Element child = DOMUtil.getFirstChildElement(curr);
child != null; child = DOMUtil.getNextSiblingElement(child)) {
String name = DOMUtil.getLocalName(child);
if (!name.equals(elementSought))
result += changeRedefineGroup(originalQName, elementSought, newName, child, schemaDoc);
else {
String ref = child.getAttribute( SchemaSymbols.ATT_REF );
if (ref.length() != 0) {
String processedRef = findQName(ref, schemaDoc);
if (originalQName.equals(processedRef)) {
String prefix = XMLSymbols.EMPTY_STRING;
int colonptr = ref.indexOf(":");
if (colonptr > 0) {
prefix = ref.substring(0,colonptr);
child.setAttribute(SchemaSymbols.ATT_REF, prefix + ":" + newName);
}
else
child.setAttribute(SchemaSymbols.ATT_REF, newName);
result++;
if (elementSought.equals(SchemaSymbols.ELT_GROUP)) {
String minOccurs = child.getAttribute( SchemaSymbols.ATT_MINOCCURS );
String maxOccurs = child.getAttribute( SchemaSymbols.ATT_MAXOCCURS );
if (!((maxOccurs.length() == 0 || maxOccurs.equals("1"))
&& (minOccurs.length() == 0 || minOccurs.equals("1")))) {
reportSchemaError("src-redefine.6.1.2", new Object [] {ref}, child);
}
}
}
} // if ref was null some other stage of processing will flag the error
}
}
return result;
}
示例9: setSchemasVisible
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
private void setSchemasVisible(XSDocumentInfo startSchema) {
if (DOMUtil.isHidden(startSchema.fSchemaElement, fHiddenNodes)) {
// make it visible
DOMUtil.setVisible(startSchema.fSchemaElement, fHiddenNodes);
Vector dependingSchemas = (Vector)fDependencyMap.get(startSchema);
for (int i = 0; i < dependingSchemas.size(); i++) {
setSchemasVisible((XSDocumentInfo)dependingSchemas.elementAt(i));
}
}
// if it's visible already than so must be its children
}
示例10: isAttrOrAttrGroup
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
private boolean isAttrOrAttrGroup(Element e) {
String elementName = DOMUtil.getLocalName(e);
if (elementName.equals(SchemaSymbols.ELT_ATTRIBUTE) ||
elementName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP) ||
elementName.equals(SchemaSymbols.ELT_ANYATTRIBUTE))
return true;
else
return false;
}
示例11: genAnonTypeName
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
private String genAnonTypeName(Element complexTypeDecl) {
// Generate a unique name for the anonymous type by concatenating together the
// names of parent nodes
// The name is quite good for debugging/error purposes, but we may want to
// revisit how this is done for performance reasons (LM).
StringBuffer typeName = new StringBuffer("#AnonType_");
Element node = DOMUtil.getParent(complexTypeDecl);
while (node != null && (node != DOMUtil.getRoot(DOMUtil.getDocument(node)))) {
typeName.append(node.getAttribute(SchemaSymbols.ATT_NAME));
node = DOMUtil.getParent(node);
}
return typeName.toString();
}
示例12: checkNotationType
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
/**
* Element/Attribute traversers call this method to check whether
* the type is NOTATION without enumeration facet
*/
void checkNotationType(String refName, XSTypeDefinition typeDecl, Element elem) {
if (typeDecl.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE &&
((XSSimpleType)typeDecl).getVariety() == XSSimpleType.VARIETY_ATOMIC &&
((XSSimpleType)typeDecl).getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION) {
if ((((XSSimpleType)typeDecl).getDefinedFacets() & XSSimpleType.FACET_ENUMERATION) == 0) {
reportSchemaError("enumeration-required-notation", new Object[]{typeDecl.getName(), refName, DOMUtil.getLocalName(elem)}, elem);
}
}
}
示例13: parseURI
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
/**
* Parse an XML document from a location identified by an URI reference.
* If the URI contains a fragment identifier (see section 4.1 in ), the
* behavior is not defined by this specification.
*
*/
public Document parseURI (String uri) throws LSException {
//If DOMParser insstance is already busy parsing another document when this
// method is called, then raise INVALID_STATE_ERR according to DOM L3 LS spec
if ( fBusy ) {
throw newInvalidStateError();
}
XMLInputSource source = new XMLInputSource (null, uri, null);
try {
currentThread = Thread.currentThread();
fBusy = true;
parse (source);
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
//reset interrupt state
abortNow = false;
Thread.interrupted();
}
} catch (Exception e){
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
Thread.interrupted();
}
if (abortNow) {
abortNow = false;
restoreHandlers();
return null;
}
// Consume this exception if the user
// issued an interrupt or an abort.
if (e != Abort.INSTANCE) {
if (!(e instanceof XMLParseException) && fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl ();
error.fException = e;
error.fMessage = e.getMessage ();
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
fErrorHandler.getErrorHandler ().handleError (error);
}
if (DEBUG) {
e.printStackTrace ();
}
throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
}
}
Document doc = getDocument();
dropDocumentReferences();
return doc;
}
示例14: parse
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
/**
* Parse an XML document from a resource identified by an
* <code>LSInput</code>.
*
*/
public Document parse (LSInput is) throws LSException {
// need to wrap the LSInput with an XMLInputSource
XMLInputSource xmlInputSource = dom2xmlInputSource (is);
if ( fBusy ) {
throw newInvalidStateError();
}
try {
currentThread = Thread.currentThread();
fBusy = true;
parse (xmlInputSource);
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
//reset interrupt state
abortNow = false;
Thread.interrupted();
}
} catch (Exception e) {
fBusy = false;
if (abortNow && currentThread.isInterrupted()) {
Thread.interrupted();
}
if (abortNow) {
abortNow = false;
restoreHandlers();
return null;
}
// Consume this exception if the user
// issued an interrupt or an abort.
if (e != Abort.INSTANCE) {
if (!(e instanceof XMLParseException) && fErrorHandler != null) {
DOMErrorImpl error = new DOMErrorImpl ();
error.fException = e;
error.fMessage = e.getMessage ();
error.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
fErrorHandler.getErrorHandler().handleError (error);
}
if (DEBUG) {
e.printStackTrace ();
}
throw (LSException) DOMUtil.createLSException(LSException.PARSE_ERR, e).fillInStackTrace();
}
}
Document doc = getDocument();
dropDocumentReferences();
return doc;
}
示例15: traverseGlobalDecl
import org.apache.xerces.util.DOMUtil; //导入依赖的package包/类
protected Object traverseGlobalDecl(int declType, Element decl, XSDocumentInfo schemaDoc, SchemaGrammar grammar) {
Object retObj = null;
DOMUtil.setHidden(decl, fHiddenNodes);
SchemaNamespaceSupport nsSupport = null;
// if the parent is <redefine> use the namespace delcs for it.
Element parent = DOMUtil.getParent(decl);
if (DOMUtil.getLocalName(parent).equals(SchemaSymbols.ELT_REDEFINE))
nsSupport = (SchemaNamespaceSupport)fRedefine2NSSupport.get(parent);
// back up the current SchemaNamespaceSupport, because we need to provide
// a fresh one to the traverseGlobal methods.
schemaDoc.backupNSSupport(nsSupport);
// traverse the referenced global component
switch (declType) {
case TYPEDECL_TYPE :
if (DOMUtil.getLocalName(decl).equals(SchemaSymbols.ELT_COMPLEXTYPE)) {
retObj = fComplexTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
}
else {
retObj = fSimpleTypeTraverser.traverseGlobal(decl, schemaDoc, grammar);
}
break;
case ATTRIBUTE_TYPE :
retObj = fAttributeTraverser.traverseGlobal(decl, schemaDoc, grammar);
break;
case ELEMENT_TYPE :
retObj = fElementTraverser.traverseGlobal(decl, schemaDoc, grammar);
break;
case ATTRIBUTEGROUP_TYPE :
retObj = fAttributeGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
break;
case GROUP_TYPE :
retObj = fGroupTraverser.traverseGlobal(decl, schemaDoc, grammar);
break;
case NOTATION_TYPE :
retObj = fNotationTraverser.traverse(decl, schemaDoc, grammar);
break;
case IDENTITYCONSTRAINT_TYPE :
// identity constraints should have been parsed already...
// we should never get here
break;
}
// restore the previous SchemaNamespaceSupport, so that the caller can get
// proper namespace binding.
schemaDoc.restoreNSSupport();
return retObj;
}