Bug 17195 - XmlPropery task does not support CDATA section
Summary: XmlPropery task does not support CDATA section
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.5.1
Hardware: Other other
: P3 normal (vote)
Target Milestone: 1.6
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-19 09:13 UTC by Markku Saarela
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markku Saarela 2003-02-19 09:13:59 UTC
If you define element with cdata section then the property value is not setted.

Here is fix for 
public Object processNode (Node node, String prefix, Object container) 
method to accept cdata section(this code is from end of method):

        if (node.getNodeType() == Node.TEXT_NODE) {
            // If the containing object was a String, then use it as the ID.
            if (semanticAttributes && id == null 
                && container instanceof String) {
                id = (String) container;
            }
            // For the text node, add a property.
            String nodeText = getAttributeValue(node);
            if (nodeText.trim().length() != 0) {
              addProperty(prefix, nodeText, id);
            }
        } else if ((node.getNodeType() == Node.ELEMENT_NODE) 
            && (node.getChildNodes().getLength() == 1)
            && (node.getFirstChild().getNodeType() == Node.CDATA_SECTION_NODE)) 
{
            // CDATA section              
            // If the containing object was a String, then use it as the ID.
            if (semanticAttributes && id == null
                && container instanceof String) {
                id = (String) container;
            }
            // For the cdata-section node, add a property.
            String nodeText = node.getFirstChild().getNodeValue();
            addProperty(prefix, nodeText, id);
        }

Regards
Markku Saarela
markku.saarela@entra.fi
Comment 1 Conor MacNeill 2003-06-24 11:32:24 UTC
Fixed in CVS.

I committed a slightly different patch since I wanted to avoid duplicating the
code in the if and else legs

Thanks