xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David_N_Bert...@lotus.com
Subject Re: Embedding XML within XML Problem
Date Wed, 04 Apr 2001 21:40:48 GMT

Have you thought about using the XSLT document() function to load the
external XML instead of embedding it in an internal file?  You could
certainly generate the internal XML with a URL to the external file.

The PI nodes you are seeing are put there by Xalan to indicate to the
serializer that disable-output-escaping was turned on for the following
Text node.  Since XSLT has no concept of CDATA section nodes, trying to
generate CDATA sections the way you're doing it is not the way to go.
Instead, look at the cdata-section-elements attribute of xsl:output, which
is the officially sanctioned way to generate CDATA sections in XML output.

Embedding an XML document or fragment within another XML document as a
CDATA section is a real abuse of CDATA sections, IMHO.

Dave



                                                                                         
                                           
                    Arvind Bassi                                                         
                                           
                    <arvind_bassi@ya        To:     general@xml.apache.org            
                                              
                    hoo.co.uk>              cc:     (bcc: David N Bertoni/CAM/Lotus)  
                                              
                                            Subject:     Embedding XML within XML Problem
                                           
                    04/04/2001 10:22                                                     
                                           
                    AM                                                                   
                                           
                    Please respond                                                       
                                           
                    to general                                                           
                                           
                                                                                         
                                           
                                                                                         
                                           



There are two questions located at the base of this email.

The project that l am working on at present, has the following flow:

1. Obtain external XML
2. Transform external XML to internal XML format, with external XML
embedded inside internal XML
3. Process transaction inside internal XML document (as part of this
store the external XML document embedded inside)
4. Obtain query results from database and produce an internal XML
document
5. Transform this internal XML document to an external XML format
6. Send external XML

I am using Xalan-J, and my parser is Xerces-J which ships with it.

I have handled (or tried to handle) the embedding and extraction of the
external XML as so:

1. I have embedded the external XML inside a tag called <Message_type>.
The external XML is wrapped inside a CDATA Section.
2. I have tried to extract the CDATA section using Xerces-J.

However, when Xerces-J encounters the CDATA Section it treats the
opening CDATA clause as a Node.PROCESSING_INSTRUCTION_NODE, aswell as
the closing CDATA clause. The embedded XML document is treated like a
document fragment, and thus l would need to iterate through it and use
code to generate a String from it.

Therefore, this has come to an impasse.

QUESTION 1:
Is there a better way to handle this situation of embedding an XML
document, and later retrieving it?

QUESTION 2:
Moreover, what is the most efficient way of converting a whole
Document() into a String? I do not know how to do this, e.g.

    public String getStringFromDocument(Document doc){

        String s = null;

        ???????????? s = doc ?????????????

        return s;
    }

I was wondering if l can transform the whole Document() into a String,
then l could use String manipulation methods to isolate the CDATA
Section and extract the original XML document as a String.

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org






---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message