axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andreas Veithen" <andreas.veit...@gmail.com>
Subject Re: [Axis2] CData elements losing text
Date Wed, 07 Jan 2009 23:25:59 GMT
Chris,

It is indeed incorrect to pass a null factory into the constructors.
However, I am surprised you didn't get an exception, and I would like
to check that with the latest Axiom version. Can you post the exact
code that shows this behavior?

Andreas

On Thu, Jan 8, 2009 at 00:00, Chris Bowman <chris@phoros.co.uk> wrote:
> Andreas,
> I wrote a stand alone, using the factory methods to create an OMElement
> as opposed to using the OMElementImpl.
> Code here:
> public class Main {
>     /**
>      * @param args the command line arguments
>      */
>     public static void main(String[] args) {
>         OMFactory factory = OMAbstractFactory.getOMFactory();
>         OMNamespace ns =
> OMAbstractFactory.getOMFactory().createOMNamespace("http://xxx/WS/v0.1",
> "ao");
>
>         //create parent node
>         OMElement fieldNode = factory.createOMElement("fieldNode", ns,
> null);
>
>         //create node I want to add CData text to
>         OMElement displayNameNode =
> factory.createOMElement("displayNameNode", ns, null);
>
>         //create text element and set type to CData
>         OMTextImpl text = (OMTextImpl)factory.createOMText("test",
> OMTextImpl.CDATA_SECTION_NODE);
>
>         //add text element and print it
>         displayNameNode.addChild(text);
>         System.out.println(displayNameNode);
>
>         fieldNode.addChild(displayNameNode);
>         System.out.println(fieldNode);
>     }
> }
> This worked!
> I then changed the real code to use factory methods, and this also works.
> It's been a long and frustrating day (UK time here), but thanks for asking
> me to rewrite this.
> Out of interest I changed it to use OMElementImpl again:
> public class Main {
>     /**
>      * @param args the command line arguments
>      */
>     public static void main(String[] args) {
>         OMFactory factory = OMAbstractFactory.getOMFactory();
>         OMNamespace ns =
> OMAbstractFactory.getOMFactory().createOMNamespace("http://xxx/WS/v0.1",
> "ao");
>
>         //create parent node
>         OMElementImpl fieldNode = new OMElementImpl("fieldNode", ns,
> factory);
>
>         //create node I want to add CData text to
>         OMElementImpl displayNameNode = new OMElementImpl("displayName", ns,
> factory);
>
>         //create text element and set type to CData
>         OMTextImpl text = (OMTextImpl)factory.createOMText("test",
> OMTextImpl.CDATA_SECTION_NODE);
>
>         //add text element and print it
>         displayNameNode.addChild(text);
>         System.out.println(displayNameNode);
>
>         fieldNode.addChild(displayNameNode);
>         System.out.println(fieldNode);
>     }
> }
> This also works. The error was in setting the factory to null. Very foolish,
> I admit.
> Thanks again for the prod to think my way out of a blonde moment.
> Chris
>
>
> On 7 Jan 2009, at 21:09, Andreas Veithen wrote:
>
> Can you please post a Java program (with no dependencies other than
> Axiom) that reproduces this problem?
>
> Andreas
>
> On Wed, Jan 7, 2009 at 16:15, Chris Bowman <chris@phoros.co.uk> wrote:
>
> Hi,
>
> I am trying to add text to an OMElement so it is surrounded by CData
>
> tags. However, when I add my created OMElement as a child to another
>
> element, the wrapped text is lost.
>
> As far as I can see this should work:
>
> OMElementImpl displayNameNode = new OMElementImpl("displayName", ns, null);
>
>        if(cf.getDisplayName() != null){
>
>            OMTextImpl text = (OMTextImpl)factory.createOMText("test",
>
> OMTextImpl.CDATA_SECTION_NODE);
>
>            logger.debug(text.getText());
>
>            displayNameNode.addChild(text);
>
>            logger.debug(displayNameNode);
>
>        }
>
>        fieldNode.addChild(displayNameNode);
>
>        logger.debug(fieldNode);
>
> Checking the logs, I  can see the correct text coming out from the debug:
>
> 07 Jan 2009 14:32:56,168 DEBUG [CampaignDataAccessWS:398]  test
>
> Again, when I check that the displayNameNode has been created properly I can
>
> see the text fine:
>
> <ao:displayName
>
> xmlns:ao="http://xxx/WS/v0.1"><![CDATA[test]]></ao:displayName>
>
> When I add this node as a child I get the problem:
>
> <ao:field xmlns:ao="http://xxx/WS/v0.1" ao:columnName="Mod_Date" ao:type="8"
>
> ao:order="5"><ao:displayName><![CDATA[]]></ao:displayName></ao:field>
>
> I am assuming I am doing something wrong here, but I cannot see what it is.
>
> Any help would be much appreciated.
>
> Chris
>
>
>
>
>

Mime
View raw message