1 16 17 package org.apache.xerces.impl.xs.traversers; 18 19 import org.apache.xerces.impl.xs.SchemaGrammar; 20 import org.apache.xerces.impl.xs.SchemaSymbols; 21 import org.apache.xerces.impl.xs.XSAnnotationImpl; 22 import org.apache.xerces.impl.xs.XSNotationDecl; 23 import org.apache.xerces.util.DOMUtil; 24 import org.w3c.dom.Element ; 25 26 44 class XSDNotationTraverser extends XSDAbstractTraverser { 45 46 XSDNotationTraverser (XSDHandler handler, 47 XSAttributeChecker gAttrCheck) { 48 super(handler, gAttrCheck); 49 } 50 51 XSNotationDecl traverse(Element elmNode, 52 XSDocumentInfo schemaDoc, 53 SchemaGrammar grammar) { 54 55 Object [] attrValues = fAttrChecker.checkAttributes(elmNode, true, schemaDoc); 57 String nameAttr = (String ) attrValues[XSAttributeChecker.ATTIDX_NAME]; 59 60 String publicAttr = (String ) attrValues[XSAttributeChecker.ATTIDX_PUBLIC]; 61 String systemAttr = (String ) attrValues[XSAttributeChecker.ATTIDX_SYSTEM]; 62 if (nameAttr == null) { 63 reportSchemaError("s4s-att-must-appear", new Object []{SchemaSymbols.ELT_NOTATION, SchemaSymbols.ATT_NAME}, elmNode); 64 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 65 return null; 66 } 67 68 if (systemAttr == null && publicAttr == null) 69 reportSchemaError("PublicSystemOnNotation", null, elmNode); 70 71 XSNotationDecl notation = new XSNotationDecl(); 72 notation.fName = nameAttr; 73 notation.fTargetNamespace = schemaDoc.fTargetNamespace; 74 notation.fPublicId = publicAttr; 75 notation.fSystemId = systemAttr; 76 77 Element content = DOMUtil.getFirstChildElement(elmNode); 79 XSAnnotationImpl annotation = null; 80 81 if (content != null && DOMUtil.getLocalName(content).equals(SchemaSymbols.ELT_ANNOTATION)) { 82 annotation = traverseAnnotationDecl(content, attrValues, false, schemaDoc); 83 content = DOMUtil.getNextSiblingElement(content); 84 } 85 else { 86 String text = DOMUtil.getSyntheticAnnotation(elmNode); 87 if (text != null) { 88 annotation = traverseSyntheticAnnotation(elmNode, text, attrValues, false, schemaDoc); 89 } 90 } 91 notation.fAnnotation = annotation; 92 if (content!=null){ 93 Object [] args = new Object [] {SchemaSymbols.ELT_NOTATION, "(annotation?)", DOMUtil.getLocalName(content)}; 94 reportSchemaError("s4s-elt-must-match.1", args, content); 95 96 } 97 grammar.addGlobalNotationDecl(notation); 98 fAttrChecker.returnAttrArray(attrValues, schemaDoc); 99 100 return notation; 101 } 102 } 103 | Popular Tags |