|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.cassinidivision.oce.content.XMLParser
This class parses content in an internal XML format from a file or string, pushing all created objects into a designated target parent.
The content objects themselves have the necessary import logic from their tag information, so this object simply acts as a stack of current content items being imported. All messages to do with parsed XML are sent to the content item on top of the stack.
The messages sent to the content objects on the stack are named identically to the parsing methods (startElement, endElement and characterData). The return values and arguments differ somewhat. The arguments are cleaned up; only local tag names are passed on, as the XML content importing does not recognise namespaces. Argument types are also rendered more WebObjects-friendly: character data is turned into a string, and attributes are turned into dictionaries.
The return values allow the content objects receiving the messages to have some control over their life on the top of the stack. When a startElement message is sent to a content object, it must return the new child if it wishes to have one put on the stack. If not, it can return null, and will remain on the top. Similarly, in endElement, the object can return true (to be removed from the stack) or false (to stay there).
The only content object which currently uses this system to customise its XML handling is C_TextContent. There are further child tags inside C_TextContent tags, but the text content object remains on top of the stack while it handles all these start/end tags and cdata blocks itself.
| Constructor Summary | |
XMLParser()
|
|
| Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Called automatically while parsing; deals with character data by passing it to the top object on the stack. |
void |
endElement(String uri,
String localName,
String qName)
Called automatically while parsing; deals with an ending tag by passing it to the top object on the stack. |
void |
parseXML()
Parses the xml in the file or string provided, putting the resulting objects into the target parent. |
void |
setTargetParent(C_ContentContainer value)
Sets the parent content item into which all imported items will be placed. |
void |
setXmlPath(String value)
Sets the receiver to take input from a file. |
void |
setXmlString(String value)
Sets the receiver to take input from a string. |
void |
startElement(String uri,
String local,
String raw,
Attributes attrs)
Called automatically while parsing; deals with a starting tag. |
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public XMLParser()
| Method Detail |
public void setXmlPath(String value)
value - the path to the input filepublic void setXmlString(String value)
value - the stringpublic void setTargetParent(C_ContentContainer value)
value - the parent content item for the importpublic void parseXML()
public void startElement(String uri,
String local,
String raw,
Attributes attrs)
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void characters(char[] ch,
int start,
int length)
ContentHandler.characters(char[], int, int)
public void endElement(String uri,
String localName,
String qName)
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||