Getting XML documents from Tamino - problem & amp;

:rolleyes:

Hello,

when I retrieve an XML-document from the Tamino database via dbhandler.getDocument(), & amp; gets converted to a simple &. Why?

Retrieving the same XML-document via the Interactive Interface shows & amp; without any conversion.

Thanks for your reply.

Dominik

Hi Dominik,

When I use the Tamino Interactive Interface using Internet Explorer and query for document that have the ampersand entity, the results show the & as an ampersand even though the document contains & So IE does convert because it styles the XML document using html.

When you use dbhandler.getDocument() what do you really mean? getDocument() gets the whole Tamino response object (if we are talking about TaminoAPI4J), and this is just a Document object. So my question is how do you know it gets converted, i.e. in what context do you see it converted. I think the conversion is correct. If I query Tamino using Tamino4J and then iterate the result set looking for particular elements (say Title elements), e.g,

  
            TResponse tresp = tacc.query (query) ;
            TXMLObjectIterator ti = tresp.getXMLObjectIterator() ;
            while (ti.hasNext())
            {
                Element d = (Element)ti.next().getElement();
                NodeList n = d.getElementsByTagName("Title");

                for (int i = 0; i < n.getLength(); i++)
                        System.out.println (n.item(i).getFirstChild().getNodeValue());
            }



then the resulting text elements that are printed out using the DOM method getNodeValue() will have the & converted to &. The DOM implementation does this. I must admit I cannot find anything concrete on this subject and no doubt there will be an article somewhere on this subject. But I think this is correct. If you have a string representation of an entity then what is the meaning of retaining the entity? It has no meaning in the context of the string and only has meaning in the context of the entire document.

Maybe one of the W3C experts may be able to give a more precise answer.

Kind regards,

Stuart Fyffe-Collins
Software AG (UK) Ltd.

Thanks very much for your response. I know that IE only shows & and not & amp;, but if you use another browser, you can see that the code corresponds to “& amp”.

After having retrieved the XML document from Tamino, I would like to pass it together with an XSL to Xalan/Xerces in order to get an HTML document. This normally works well.

But, iff there is an & amp; stored in Tamino, the conversion fails. Error: the parser is expecting an entity. I think the document got converted before; if I print out the DOM-document with doc.toString() I cannot see any & amp; but only &.

Best regards,
Dominik Stankowski

Hello Stuart,

if I use the method “document()” in the XSL to get the corresponding Tamino result, it works fine.

For example:
document("http://xxx/tamino/myDatabase/myCollection?_xql=*')

I think it’s because the parser doesn’t verify the XML-document with this method.

But how to proceed without the “document”-method?

Dominik

Hi Dominik,

It sounds to me like you are using the HTTP Client API for Java, since you are able to do getDocument().toString() and get the XML representation. Is this a correct assumption?

This won’t work with Xalan/Xerces so you need to use the TaminoAPI4J.

Stuart Fyffe-Collins
Software AG (UK) Ltd.

Yes, I am using HTTP Client API for Java.

Is there some more specific information about how to use Xalan/Xerces together with Tamino API4J?

What about the new version of Tamino (4.1)? Are there any changes concerning these transformations?

Best regards and thanks,
Dominik

Hi Dominik,

The reason I am suggesting TaminoAPI4J is that this API supports JAXP including DOM2 and SAX2 which is required by Xerces/Xalan. The old HTTP Client API for Java is in dark ages I am afraid and only supports DOM level 1 utilizing Docuverse DOM. At some point in time I see the HTTP client API being deprecated.

For information regarding TaminoAPI4J and Xalan well there really isn’t much. At the end of the day you can use TaminoAPI4J to get DOM level 2 objects and these can be used in conjunction with Xalan.

hope this helps.

Stuart Fyffe-Collins
Software AG (UK) Ltd.