public void startElement(String namespaceURI, String localName,
String qName, Attributes atts)
throws SAXException {
// check namespace
if (!QName.NS_SV_URI.equals(namespaceURI)) {
throw new SAXException(new InvalidSerializedDataException("invalid namespace for element in system view xml document: "
+ namespaceURI));
}
// check element name
if (SysViewSAXEventGenerator.NODE_ELEMENT.equals(localName)) {
// sv:node element
// node name (value of sv:name attribute)
String name = atts.getValue(SysViewSAXEventGenerator.PREFIXED_NAME_ATTRIBUTE);
if (name == null) {
throw new SAXException(new InvalidSerializedDataException(
"missing mandatory sv:name attribute of element sv:node"));
}
if (!stack.isEmpty()) {
// process current node first
ImportState current = (ImportState) stack.peek();
// need to start current node
if (!current.started) {
processNode(current, true, false);
current.started = true;
}
}
// push new ImportState instance onto the stack
ImportState state = new ImportState();
try {
state.nodeName = QName.fromJCRName(name, nsContext);
} catch (IllegalNameException ine) {
throw new SAXException(new InvalidSerializedDataException("illegal node name: " + name, ine));
} catch (UnknownPrefixException upe) {
throw new SAXException(new InvalidSerializedDataException("illegal node name: " + name, upe));
}
stack.push(state);
} else if (SysViewSAXEventGenerator.PROPERTY_ELEMENT.equals(localName)) {
// sv:property element
// reset temp fields
currentPropValues.clear();
// property name (value of sv:name attribute)
String name = atts.getValue(SysViewSAXEventGenerator.PREFIXED_NAME_ATTRIBUTE);
if (name == null) {
throw new SAXException(new InvalidSerializedDataException(
"missing mandatory sv:name attribute of element sv:property"));
}
try {
currentPropName = QName.fromJCRName(name, nsContext);
} catch (IllegalNameException ine) {
throw new SAXException(new InvalidSerializedDataException("illegal property name: " + name, ine));
} catch (UnknownPrefixException upe) {
throw new SAXException(new InvalidSerializedDataException("illegal property name: " + name, upe));
}
// property type (sv:type attribute)
String type = atts.getValue(SysViewSAXEventGenerator.PREFIXED_TYPE_ATTRIBUTE);
if (type == null) {
throw new SAXException(new InvalidSerializedDataException(
"missing mandatory sv:type attribute of element sv:property"));
}
currentPropType = PropertyType.valueFromName(type);
} else if (SysViewSAXEventGenerator.VALUE_ELEMENT.equals(localName)) {
// sv:value element
// reset temp fields
currentPropValue = new BufferedStringValue();
} else {
throw new SAXException(new InvalidSerializedDataException("unexpected element found in system view xml document: "
+ localName));
}
}