You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by "Hiranya Jayathilaka (JIRA)" <ji...@apache.org> on 2008/03/03 12:48:50 UTC

[jira] Created: (WSCOMMONS-305) OMElementImpl.getText() returns an empty String for text in CDATA tags

OMElementImpl.getText() returns an empty String for text in CDATA tags
----------------------------------------------------------------------

                 Key: WSCOMMONS-305
                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-305
             Project: WS-Commons
          Issue Type: Improvement
          Components: AXIOM
         Environment: any
            Reporter: Hiranya Jayathilaka


AXIOM supports building OM structures with CDATA elements. For an example something like,

soapFactory.createOMText(parentNode, "some text",XMLStreamConstants.CDATA);

is perfectly valid and delivers the expected result. But when traversing such an OM structure calling parentNode.getText() returns an empty String. Instead it would have been better if it returned the String without the CDATA tags. For an example calling getText() on an element like,

<parentnode><![CDATA[some text]]></parentnode>

should return the String, "some text".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Commented: (WSCOMMONS-305) OMElementImpl.getText() returns an empty String for text in CDATA tags

Posted by "Hiranya Jayathilaka (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WSCOMMONS-305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574454#action_12574454 ] 

Hiranya Jayathilaka commented on WSCOMMONS-305:
-----------------------------------------------

Simply extending the test to include CDATA elements will solve the problem of traversing structures with CDATA tags.

public String getText() {
        String childText = null;
        StringBuffer buffer = null;
        OMNode child = this.getFirstOMChild();

        while (child != null) {
            if (child.getType() == OMNode.TEXT_NODE || child.getType() == OMNode.CDATA_SECTION_NODE) {
                OMText textNode = (OMText) child;
                String textValue = textNode.getText();
                ............. 

> OMElementImpl.getText() returns an empty String for text in CDATA tags
> ----------------------------------------------------------------------
>
>                 Key: WSCOMMONS-305
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-305
>             Project: WS-Commons
>          Issue Type: Improvement
>          Components: AXIOM
>         Environment: any
>            Reporter: Hiranya Jayathilaka
>
> AXIOM supports building OM structures with CDATA elements. For an example something like,
> soapFactory.createOMText(parentNode, "some text",XMLStreamConstants.CDATA);
> is perfectly valid and delivers the expected result. But when traversing such an OM structure calling parentNode.getText() returns an empty String. Instead it would have been better if it returned the String without the CDATA tags. For an example calling getText() on an element like,
> <parentnode><![CDATA[some text]]></parentnode>
> should return the String, "some text".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Updated: (WSCOMMONS-305) OMElementImpl.getText() returns an empty String for text in CDATA tags

Posted by "Hiranya Jayathilaka (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WSCOMMONS-305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hiranya Jayathilaka updated WSCOMMONS-305:
------------------------------------------

    Attachment: svndiff.patch

This is the output of the svn diff after applying the solution described in the previous comment. This solves the problem for OM structures with CDATA tags.

> OMElementImpl.getText() returns an empty String for text in CDATA tags
> ----------------------------------------------------------------------
>
>                 Key: WSCOMMONS-305
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-305
>             Project: WS-Commons
>          Issue Type: Improvement
>          Components: AXIOM
>         Environment: any
>            Reporter: Hiranya Jayathilaka
>         Attachments: svndiff.patch
>
>
> AXIOM supports building OM structures with CDATA elements. For an example something like,
> soapFactory.createOMText(parentNode, "some text",XMLStreamConstants.CDATA);
> is perfectly valid and delivers the expected result. But when traversing such an OM structure calling parentNode.getText() returns an empty String. Instead it would have been better if it returned the String without the CDATA tags. For an example calling getText() on an element like,
> <parentnode><![CDATA[some text]]></parentnode>
> should return the String, "some text".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Commented: (WSCOMMONS-305) OMElementImpl.getText() returns an empty String for text in CDATA tags

Posted by "Hiranya Jayathilaka (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WSCOMMONS-305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12574453#action_12574453 ] 

Hiranya Jayathilaka commented on WSCOMMONS-305:
-----------------------------------------------

Problem is with the OMElementImpl.getText() method which performs a crude test on the type of the element in question.

public String getText() {
        String childText = null;
        StringBuffer buffer = null;
        OMNode child = this.getFirstOMChild();

        while (child != null) {
            if (child.getType() == OMNode.TEXT_NODE) {
                OMText textNode = (OMText) child;
                String textValue = textNode.getText();
                .............



> OMElementImpl.getText() returns an empty String for text in CDATA tags
> ----------------------------------------------------------------------
>
>                 Key: WSCOMMONS-305
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-305
>             Project: WS-Commons
>          Issue Type: Improvement
>          Components: AXIOM
>         Environment: any
>            Reporter: Hiranya Jayathilaka
>
> AXIOM supports building OM structures with CDATA elements. For an example something like,
> soapFactory.createOMText(parentNode, "some text",XMLStreamConstants.CDATA);
> is perfectly valid and delivers the expected result. But when traversing such an OM structure calling parentNode.getText() returns an empty String. Instead it would have been better if it returned the String without the CDATA tags. For an example calling getText() on an element like,
> <parentnode><![CDATA[some text]]></parentnode>
> should return the String, "some text".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Resolved: (WSCOMMONS-305) OMElementImpl.getText() returns an empty String for text in CDATA tags

Posted by "Glen Daniels (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WSCOMMONS-305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Glen Daniels resolved WSCOMMONS-305.
------------------------------------

    Resolution: Fixed

Fixed and tested in latest HEAD, thanks for the bug report!


> OMElementImpl.getText() returns an empty String for text in CDATA tags
> ----------------------------------------------------------------------
>
>                 Key: WSCOMMONS-305
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-305
>             Project: WS-Commons
>          Issue Type: Improvement
>          Components: AXIOM
>         Environment: any
>            Reporter: Hiranya Jayathilaka
>            Assignee: Glen Daniels
>         Attachments: svndiff.patch
>
>
> AXIOM supports building OM structures with CDATA elements. For an example something like,
> soapFactory.createOMText(parentNode, "some text",XMLStreamConstants.CDATA);
> is perfectly valid and delivers the expected result. But when traversing such an OM structure calling parentNode.getText() returns an empty String. Instead it would have been better if it returned the String without the CDATA tags. For an example calling getText() on an element like,
> <parentnode><![CDATA[some text]]></parentnode>
> should return the String, "some text".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


[jira] Assigned: (WSCOMMONS-305) OMElementImpl.getText() returns an empty String for text in CDATA tags

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WSCOMMONS-305?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Davanum Srinivas reassigned WSCOMMONS-305:
------------------------------------------

    Assignee: Glen Daniels

> OMElementImpl.getText() returns an empty String for text in CDATA tags
> ----------------------------------------------------------------------
>
>                 Key: WSCOMMONS-305
>                 URL: https://issues.apache.org/jira/browse/WSCOMMONS-305
>             Project: WS-Commons
>          Issue Type: Improvement
>          Components: AXIOM
>         Environment: any
>            Reporter: Hiranya Jayathilaka
>            Assignee: Glen Daniels
>         Attachments: svndiff.patch
>
>
> AXIOM supports building OM structures with CDATA elements. For an example something like,
> soapFactory.createOMText(parentNode, "some text",XMLStreamConstants.CDATA);
> is perfectly valid and delivers the expected result. But when traversing such an OM structure calling parentNode.getText() returns an empty String. Instead it would have been better if it returned the String without the CDATA tags. For an example calling getText() on an element like,
> <parentnode><![CDATA[some text]]></parentnode>
> should return the String, "some text".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org