I need to place a piece of XML into an AnyNode castor class, and have tried
using a method suggested on this forum before, which uses the
org.exolab.castor.xml.util.SAX2ANY Content handler but when I eventually
marshall the root element I lose the names on the elements, any ideas please
- this is getting urgent.

XML after marshal :-

 <PAGE>
                <TITLE>Decision</TITLE>
                <FORMAT>TEXT</FORMAT>
                <HEADING>unknown</HEADING>
                <CONTENT>
                    < ="http://www.w3.org/1999/xhtml";
="http://www.w3.org/2001/XMLSchema";>
                        <>
                            <>Enter the title of your XHTML document here</>
                        </>
                        <>
                            <>      Your customer's Agreement in
                                Principle has been Pass<
="font-weight:bold"/>
                            </>
                            <>This decision is based on the information
                                provided. Should the information change,
                                for whatever reason, we reserve the

The <CONTENT> tag contains the AnyNode, as you can see all the elements
names are empty. This is supposed to ba an XHTML document embedded here.
Heres the XML String that it should be :-

<html xmlns="http://www.w3.org/1999/xhtml";
xmlns:xs="http://www.w3.org/2001/XMLSchema";><head><title>Enter the title of
your XHTML document here</title></head><body><p>
                                        Your customer's Agreement in
Principle has been Pass<span style="font-weight:bold"/></p><
....
....

And finally here's how I'm generating an AnyNode from the above String.




        public static AnyNode convertStringToAnyNode(String text)
        {
                org.exolab.castor.xml.util.SAX2ANY handler;
                try
                {
                        SAXParserFactory factory =
SAXParserFactory.newInstance();
                        SAXParser saxParser = factory.newSAXParser();
                        XMLReader reader = saxParser.getXMLReader();


                        handler = new org.exolab.castor.xml.util.SAX2ANY();

                        reader.setContentHandler(handler);
                        reader.setErrorHandler(handler);
                        InputSource source = new InputSource(new
StringReader(text));
                    reader.parse(source);
                }
                catch (SAXException e)
                {
                         throw new NRInvariantViolationException(e);
                }
                catch (ParserConfigurationException e)
                {
                         throw new NRInvariantViolationException(e);
                }
                catch (IOException ex)
                {
                        throw new NRInvariantViolationException(ex);
                }

                AnyNode anyNode = handler.getStartingNode();
                return anyNode;
        }
This transmission is confidential and intended solely for the person or
organisation to whom it is addressed.  It may contain privileged and
confidential information.  If you are not the intended recipient, you should
not copy, distribute or take any action in reliance on it. If you have
received this transmission in error, please notify the sender immediately.
Any opinions or advice contained in this e-mail are those of the individual
sender except where they are stated to be the views of RDF Group or EMS plc.
All messages passing through this gateway are virus scanned.

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to