|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.knowgate.dataxslt.XMLDocument
public class XMLDocument
Direct character-level manipulations for XML documents. This class modifies XML document files by directy seeking substrings inside its text. Given a well-knonw XML file structure is easier and faster to seek for <nodes> as substrings instead of parsing the whole documents into a DOM tree.
| Constructor Summary | |
|---|---|
XMLDocument()
|
|
XMLDocument(java.lang.String sFile)
Create XMLDocument and load an XML file into memory. |
|
XMLDocument(java.lang.String sFile,
java.lang.String sEnc)
Create XMLDocument and load an XML file into memory. |
|
| Method Summary | |
|---|---|
void |
addNode(java.lang.String sAfterXPath,
java.lang.String sNode)
Add a piece of XML text after a given node identifier by an XPath expression. |
void |
addNodeAndSave(java.lang.String sAfterXPath,
java.lang.String sNode)
Add a piece of XML text after a given node and save document. |
java.lang.String |
getCharacterEncoding()
|
void |
load(java.lang.String sFile)
Load an XML file into memory. |
void |
load(java.lang.String sFile,
java.lang.String sEnc)
Load an XML file into memory. |
void |
removeNode(java.lang.String sXPath)
Remove a node. |
void |
removeNodeAndSave(java.lang.String sXPath)
Remove a node and save document. |
void |
save()
Save file to disk. |
void |
save(java.lang.String sFile)
Save file to disk. |
void |
setCharacterEncoding(java.lang.String sEnc)
|
java.lang.String |
toString()
Get loaded file as a String |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public XMLDocument()
public XMLDocument(java.lang.String sFile)
throws java.io.IOException,
java.lang.OutOfMemoryError
Create XMLDocument and load an XML file into memory.
No node parsing is done, but file is loaded directly into a String.
sFile - File Path
java.io.IOException
java.lang.OutOfMemoryError
public XMLDocument(java.lang.String sFile,
java.lang.String sEnc)
throws java.io.IOException,
java.lang.OutOfMemoryError
sFile - File PathsEnc - Character Encoding
java.io.IOException
java.lang.OutOfMemoryError| Method Detail |
|---|
public java.lang.String getCharacterEncoding()
public void setCharacterEncoding(java.lang.String sEnc)
public void load(java.lang.String sFile,
java.lang.String sEnc)
throws java.io.IOException,
java.lang.OutOfMemoryError
sFile - File PathsEnc - Character encoding
java.io.IOException
java.lang.OutOfMemoryError
public void load(java.lang.String sFile)
throws java.io.IOException,
java.lang.OutOfMemoryError
Load an XML file into memory.
No node parsing is done, but file is loaded directly into a String.
sFile - File Path
java.io.IOException
java.lang.OutOfMemoryError
public void save(java.lang.String sFile)
throws java.io.IOException
sFile - File Path
java.io.IOException
public void save()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object
public void addNode(java.lang.String sAfterXPath,
java.lang.String sNode)
throws org.w3c.dom.DOMException
sAfterXPath - Restricted XPath expression for node after witch the next node is to be placed.
For example : sNode - XML Text to be added.
org.w3c.dom.DOMException - DOMException Codes:| NOT_FOUND_ERR | A node or attribute from the XPath expression was not found |
| INVALID_ACCESS_ERR | An attribute expression is invalid |
| NOT_SUPPORTED_ERR | position() function was used but last() was not specified as value for it |
public void addNodeAndSave(java.lang.String sAfterXPath,
java.lang.String sNode)
throws org.w3c.dom.DOMException,
java.io.IOException
sAfterXPath - Restricted XPath expression for node after witch the next node is to be placed.sNode - XML Text to be added.
org.w3c.dom.DOMException
java.io.IOException
public void removeNode(java.lang.String sXPath)
throws org.w3c.dom.DOMException
sXPath - Restricted XPath expression for node to remove.
For example: "pageset/pages/page[@guid="123456789012345678901234567890AB"]/blocks/block[@id="003"]"
will remove org.w3c.dom.DOMException
public void removeNodeAndSave(java.lang.String sXPath)
throws org.w3c.dom.DOMException,
java.io.IOException
sXPath - XPath expression for node to remove.
org.w3c.dom.DOMException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||