Package com.softwareag.tamino.db.api.accessor

Provides classes and interfaces to access and query documents stored in Tamino.

See: Description

Package com.softwareag.tamino.db.api.accessor Description

Provides classes and interfaces to access and query documents stored in Tamino.

An accessor provides access to data stored in a Tamino database or data related to Tamino database. There are several different types of accessors. First of all there is an accessor for the lowest level of access to any XML or non-XML document stored in Tamino. This is the TStreamAccessor. This accessor treats all documents as byte or character streams. It provides direct access to the response documents as they are returned by Tamino without interpreting the results. You also need to provide input documents as streams. You normally don't need to use the TStreamAccessor unless

Secondly, there are accessors that provide access on a higher level of abstraction. These are the TXMLObjectAccessor and TXMLNonObjectAccessor. The TXMLObjectAccessor is used for accessing XML documents and the TNonXMLObjectAccessor for non-XML documents. Both accessors treat documents as objects. The TXMLObjectAccessor handles TXMLObject instances and the TNonXMLObjectAccessor TNonXMLObject instances. A TXMLObjectAccessor is always based on a particular object model. The object model determines the way in which the XML document content is represented. The object model currently supported are DOM, JDOM, SAX and stream. These higher level accessors always interpret the response document returned by Tamino and present the results in TReponse instances.

Thirdly, there are a number of special purpose accessors for access to meta and system information. You can use TSchemaDefinition2Accessor and TSchemaDefinition3Accessor for accessing and manipulating TSD2 respectively TSD3 schema information. The TSystemAccessor provides access to Tamino server and Taminp API information.

The following code snippet shows how a client might work with a TXMLObjectAccessor:

    
    TAccessLocation accessLocation = TAccessLocation.newInstance( "ino:etc" );
    TXMLObjectAccessor xmlObjectAccessor = connection.newXMLObjectAccessor( accessLocation , TDOMObjectModel.getInstance() );
    // Assume there are Patient documents within ino:etc
    TResponse response = xmlObjectAccessor.query( TXQuery.newInstance( "Patient" );
    if ( response.hasQueryContent() ) {
        TXMLObjectIterator iterator = response.getXMLObjectIterator();
        while ( iterator.hasNext() ) {
                // Iterate over the result set
                TXMLObject xmlObject = iterator.next();
                StringWriter writer = new StringWriter();
                xmlObject.writeTo( writer );
                System.out.println( writer );
        }
    }
    
  

Encoding information of XML documents

Note that at the moment, the encoding information stored in the database gets lost. For TXMLObjectAccessor this is because the underlying SAX parsers ingnore the encoding info respectively for the TStreamAccessor implementation no encoding info is recognized.

Setting a specific SAXParser

To set your specific SAXParser which should be used by JAXP you have 3 possibilities (for example with the XERCES Parser):

  1. set a property like so:
    System.setProperty("javax.xml.parsers.SAXParserFactory","org.apache.xerces.jaxp.SAXParserFactoryImpl");
  2. use the java option -D:
    java -D javax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
  3. The first JAR File in the CLASSPATH which include the META-INF\services\javax.xml.parsers.SAXParserFactory File will be used to get the information about the SAXParser.
Handling of General Entities

The previous version of the API tried to set the Apache/Xerces specific feature "http://apache.org/xml/features/nonvalidating/load-external-dtd". This feature simplified the parsing of XML documents, because the DTD was not searched and so no problems came up if it was not existant or not accessible. This caused that general entities got lost. They where neither translated nor kept.
Now the API will let the parser try to translate them. To force the API to behave as in the previous version you should set the following preference property: TPreference.getInstance().setUseApacheLoadExternalDTD( false );

Copyright (c) 2017 Software AG. All Rights Reserved.