| org.apache.cocoon.transformation.AbstractTransformer org.apache.cocoon.transformation.XMLDBTransformer
XMLDBTransformer | public class XMLDBTransformer extends AbstractTransformer implements CacheableProcessingComponent,Configurable,Initializable(Code) | | This transformer allows to perform resource creation, deletion, and
XUpdate command execution in XML:DB. All operations are performed either
in base collection, or context collection, which
is specified as collection attribute on the query
element. Context collection must be specified relative to the base collection.
Definition:
<map:transformer name="xmldb" src="org.apache.cocoon.transformation.XMLDBTransformer">
<!-- Optional driver parameter. Uncomment if you want transformer to register a database.
<driver>org.apache.xindice.client.xmldb.DatabaseImpl</driver>
-->
<base>xmldb:xindice:///db/collection</base>
<user>myDatabaseLogin</user>
<password>myDatabasePassword</password>
</map:transformer>
The component configuration defined in <map:transformer> can be
overriden with sitemap parameters on the <map:transform>:
<map:transform type="xmldb">
<map:parameter name="base" value="xmldb:xindice:///db/collection"/>
<map:parameter name="user" value="myDatabaseLogin"/>
<map:parameter name="password" value="myDatabasePassword"/>
</map:transform>
Input XML document example:
<page xmlns:db="http://apache.org/cocoon/xmldb/1.0">
...
<p>Create XML resource in base collection with specified object ID</p>
<db:query type="create" oid="xmldb-object-id">
<page>
XML Object body
</page>
</db:query>
<p>Delete XML resource from the base collection with specified object ID</p>
<db:query type="delete" oid="xmldb-object-id"/>
<p>Update XML resource with specified object ID</p>
<db:query type="update" oid="xmldb-object-id">
<xu:modifications version="1.0" xmlns:xu="http://www.xmldb.org/xupdate">
<xu:remove select="/person/phone[@type = 'home']"/>
<xu:update select="/person/phone[@type = 'work']">
480-300-3003
</xu:update>
</xu:modifications>
</db:query>
<p>Create collection nested into the base collection</p>
<db:query type="create" oid="inner/"/>
<p>Create XML resource in context collection with specified object ID</p>
<db:query type="create" collection="inner" oid="xmldb-object-id">
<page>
XML Object body
</page>
</db:query>
...
</page>
Output XML document example:
<page xmlns:db="http://apache.org/cocoon/xmldb/1.0">
...
<db:query type="create" oid="xmldb-object-id" result="success"/>
<db:query type="delete" oid="xmldb-object-id" result="success"/>
<db:query type="update" oid="xmldb-object-id" result="failure">
Resource xmldb-object-id is not found
</db:query>
...
</page>
Known bugs and limitations:
- No namespaces with Xalan (see AbstractTextSerializer)
version: $Id: XMLDBTransformer.java 433543 2006-08-22 06:22:54Z crossley $ |
Method Summary | |
public void | characters(char c, int start, int len) Receive notification of character data. | public void | comment(char ch, int start, int len) Report an XML comment anywhere in the document. | public void | configure(Configuration configuration) | public void | endCDATA() Report the end of a CDATA section. | public void | endDTD() Report the end of DTD declarations. | public void | endDocument() Receive notification of the end of a document. | public void | endElement(String uri, String loc, String raw) Receive notification of the end of an element. | public void | endEntity(String name) Report the end of an entity. | public void | endPrefixMapping(String prefix) End the scope of a prefix-URI mapping. | public Serializable | getKey() Generate the unique key. | protected SAXTransformerFactory | getTransformerFactory() Helper for TransformerFactory. | public SourceValidity | getValidity() Generate the validity object. | public void | ignorableWhitespace(char c, int start, int len) Receive notification of ignorable whitespace in element content. | public void | initialize() Initializes XML:DB database instance if driver class was configured. | public void | processingInstruction(String target, String data) Receive notification of a processing instruction. | public void | recycle() | public void | setup(SourceResolver resolver, Map objectModel, String src, Parameters par) Setup the transformer. | public void | skippedEntity(String name) Receive notification of a skipped entity.
Parameters: name - The name of the skipped entity. | public void | startCDATA() Report the start of a CDATA section. | public void | startDTD(String name, String publicId, String systemId) Report the start of DTD declarations, if any. | public void | startDocument() Receive notification of the beginning of a document. | public void | startElement(String uri, String loc, String raw, Attributes a) Receive notification of the beginning of an element.
Parameters: uri - The Namespace URI, or the empty string if the element has noNamespace URI or if Namespaceprocessing is not being performed. Parameters: loc - The local name (without prefix), or the empty string ifNamespace processing is not being performed. Parameters: raw - The raw XML 1.0 name (with prefix), or the empty string ifraw names are not available. Parameters: a - The attributes attached to the element. | public void | startEntity(String name) Report the beginning of an entity.
Parameters: name - The name of the entity. | public void | startPrefixMapping(String prefix, String uri) Begin the scope of a prefix-URI Namespace mapping. |
XMLDBTransformer | public XMLDBTransformer()(Code) | | |
characters | public void characters(char c, int start, int len) throws SAXException(Code) | | Receive notification of character data.
Parameters: c - The characters from the XML document. Parameters: start - The start position in the array. Parameters: len - The number of characters to read from the array. |
comment | public void comment(char ch, int start, int len) throws SAXException(Code) | | Report an XML comment anywhere in the document.
Parameters: ch - An array holding the characters in the comment. Parameters: start - The starting position in the array. Parameters: len - The number of characters to use from the array. |
configure | public void configure(Configuration configuration) throws ConfigurationException(Code) | | |
endCDATA | public void endCDATA() throws SAXException(Code) | | Report the end of a CDATA section.
|
endDocument | public void endDocument() throws SAXException(Code) | | Receive notification of the end of a document.
|
endElement | public void endElement(String uri, String loc, String raw) throws SAXException(Code) | | Receive notification of the end of an element.
Parameters: uri - The Namespace URI, or the empty string if the element has noNamespace URI or if Namespaceprocessing is not being performed. Parameters: loc - The local name (without prefix), or the empty string ifNamespace processing is not being performed. Parameters: raw - The raw XML 1.0 name (with prefix), or the empty string ifraw names are not available. |
endEntity | public void endEntity(String name) throws SAXException(Code) | | Report the end of an entity.
Parameters: name - The name of the entity that is ending. |
endPrefixMapping | public void endPrefixMapping(String prefix) throws SAXException(Code) | | End the scope of a prefix-URI mapping.
Parameters: prefix - The prefix that was being mapping. |
getKey | public Serializable getKey()(Code) | | Generate the unique key.
This key must be unique inside the space of this component.
This method must be invoked before the generateValidity() method.
The generated key or null if the componentis currently not cacheable. |
getValidity | public SourceValidity getValidity()(Code) | | Generate the validity object.
Before this method can be invoked the generateKey() method
must be invoked.
The generated validity object or null if thecomponent is currently not cacheable. |
ignorableWhitespace | public void ignorableWhitespace(char c, int start, int len) throws SAXException(Code) | | Receive notification of ignorable whitespace in element content.
Parameters: c - The characters from the XML document. Parameters: start - The start position in the array. Parameters: len - The number of characters to read from the array. |
initialize | public void initialize() throws Exception(Code) | | Initializes XML:DB database instance if driver class was configured.
|
processingInstruction | public void processingInstruction(String target, String data) throws SAXException(Code) | | Receive notification of a processing instruction.
Parameters: target - The processing instruction target. Parameters: data - The processing instruction data, or null if none wassupplied. |
recycle | public void recycle()(Code) | | |
skippedEntity | public void skippedEntity(String name) throws SAXException(Code) | | Receive notification of a skipped entity.
Parameters: name - The name of the skipped entity. If it is a parameterentity, the name will begin with '%'. |
startCDATA | public void startCDATA() throws SAXException(Code) | | Report the start of a CDATA section.
|
startDTD | public void startDTD(String name, String publicId, String systemId) throws SAXException(Code) | | Report the start of DTD declarations, if any.
Parameters: name - The document type name. Parameters: publicId - The declared public identifier for the external DTDsubset, or null if none was declared. Parameters: systemId - The declared system identifier for the external DTDsubset, or null if none was declared. |
startDocument | public void startDocument() throws SAXException(Code) | | Receive notification of the beginning of a document.
|
startElement | public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException(Code) | | Receive notification of the beginning of an element.
Parameters: uri - The Namespace URI, or the empty string if the element has noNamespace URI or if Namespaceprocessing is not being performed. Parameters: loc - The local name (without prefix), or the empty string ifNamespace processing is not being performed. Parameters: raw - The raw XML 1.0 name (with prefix), or the empty string ifraw names are not available. Parameters: a - The attributes attached to the element. If there are noattributes, it shall be an empty Attributes object. |
startEntity | public void startEntity(String name) throws SAXException(Code) | | Report the beginning of an entity.
Parameters: name - The name of the entity. If it is a parameter entity, thename will begin with '%'. |
startPrefixMapping | public void startPrefixMapping(String prefix, String uri) throws SAXException(Code) | | Begin the scope of a prefix-URI Namespace mapping.
Parameters: prefix - The Namespace prefix being declared. Parameters: uri - The Namespace URI the prefix is mapped to. |
|
|