in src/main/java/org/apache/xmlgraphics/xmp/XMPHandler.java [119:199]
public void startElement(String uri, String localName, String qName, Attributes attributes)
throws SAXException {
super.startElement(uri, localName, qName, attributes);
content.setLength(0); //Reset text buffer (see characters())
attributesStack.push(new AttributesImpl(attributes));
if (XMPConstants.XMP_NAMESPACE.equals(uri)) {
if (!"xmpmeta".equals(localName)) {
throw new SAXException("Expected x:xmpmeta element, not " + qName);
}
if (this.meta != null) {
throw new SAXException("Invalid XMP document. Root already received earlier.");
}
this.meta = new Metadata();
this.contextStack.push(this.meta);
this.nestingInfoStack.push("metadata");
} else if (XMPConstants.RDF_NAMESPACE.equals(uri)) {
if ("RDF".equals(localName)) {
if (this.meta == null) {
this.meta = new Metadata();
this.contextStack.push(this.meta);
this.nestingInfoStack.push("metadata");
}
} else if ("Description".equals(localName)) {
String about = attributes.getValue(XMPConstants.RDF_NAMESPACE, "about");
for (int i = 0, c = attributes.getLength(); i < c; i++) {
String ns = attributes.getURI(i);
if (XMPConstants.RDF_NAMESPACE.equals(ns)) {
//ignore
} else if (XMPConstants.XMLNS_NAMESPACE.equals(ns)) {
//ignore
} else if ("".equals(ns)) {
//ignore
} else {
String qn = attributes.getQName(i);
String v = attributes.getValue(i);
XMPProperty prop = new XMPProperty(new QName(ns, qn), v);
prop.attribute = true;
getCurrentProperties().setProperty(prop);
}
}
if (this.contextStack.peek().equals(this.meta)) {
//rdf:RDF is the parent
} else {
if (about != null) {
throw new SAXException(
"Nested rdf:Description elements may not have an about property");
}
startStructure();
}
} else if ("Seq".equals(localName)) {
XMPArray array = new XMPArray(XMPArrayType.SEQ);
this.contextStack.push(array);
this.nestingInfoStack.push("Seq");
} else if ("Bag".equals(localName)) {
XMPArray array = new XMPArray(XMPArrayType.BAG);
this.contextStack.push(array);
this.nestingInfoStack.push("Bag");
} else if ("Alt".equals(localName)) {
XMPArray array = new XMPArray(XMPArrayType.ALT);
this.contextStack.push(array);
this.nestingInfoStack.push("Alt");
} else if ("li".equals(localName)) {
//nop, handle in endElement()
} else if ("value".equals(localName)) {
QName name = new QName(uri, qName);
this.contextStack.push(name);
this.nestingInfoStack.push("prop:" + name);
} else {
throw new SAXException("Unexpected element in the RDF namespace: " + localName);
}
} else {
if (getCurrentPropName() != null) {
//Structure (shorthand form)
startStructure();
}
QName name = new QName(uri, qName);
this.contextStack.push(name);
this.nestingInfoStack.push("prop:" + name);
}
}