You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2018/02/20 09:39:47 UTC

[royale-asjs] 02/02: Fixed toXMLString() of CDATA sections

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit aacd60bcb54d989f56fab07517ccfdda3c8831f0
Author: Harbs <ha...@in-tools.com>
AuthorDate: Tue Feb 20 11:39:37 2018 +0200

    Fixed toXMLString() of CDATA sections
---
 frameworks/projects/XML/src/main/royale/XML.as |  4 ++++
 manualtests/XMLTest/src/MyInitialView.mxml     | 16 +++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index 4934521..b13fada 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -2510,8 +2510,12 @@ package
 				if(prettyPrinting)
 				{
 					var v:String = trimXMLWhitespace(_value);
+					if(name().localName == "#cdata-section")
+						return indent + v;
 					return indent + escapeElementValue(v);
 				}
+				if(name().localName == "#cdata-section")
+					return _value;
 				return escapeElementValue(_value);
 			}
 			if(this.nodeKind() == "attribute")
diff --git a/manualtests/XMLTest/src/MyInitialView.mxml b/manualtests/XMLTest/src/MyInitialView.mxml
index 72e21a5..1e42c42 100644
--- a/manualtests/XMLTest/src/MyInitialView.mxml
+++ b/manualtests/XMLTest/src/MyInitialView.mxml
@@ -152,7 +152,21 @@ limitations under the License.
         childXML = <Content>	• <?ACE 7?>Some amazing content</Content>;
 				childXMLStr = childXML.text();
 				trace(childXMLStr + " (should be) \t• Some amazing content? " + (childXMLStr == "\t• Some amazing content"));
-        
+        XML.ignoreWhitespace = true;
+        XML.prettyPrinting = false;
+        var content:XML = new XML(
+'<root>' +
+'	<content><![CDATA[<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>' +
+'<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27        ">' +
+'   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
+'      <rdf:Description rdf:about=""/>' +
+'   </rdf:RDF>' +
+'</x:xmpmeta>' +
+'<?xpacket end="r"?>]'+']></content>' +
+'</root>');
+var contentStr:String = content.toXMLString();
+var correctStr:String = '<root><content><![CDATA[<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?><x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27        ">   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">      <rdf:Description rdf:about=""/>   </rdf:RDF></x:xmpmeta><?xpacket end="r"?>]'+']></content></root>';
+trace("content with cdata works? " + (contentStr == correctStr));
         var xmlString:String = xml.toXMLString();
         var script:XML = xml..script[0].children()[0];
         var kind:String = script.nodeKind();

-- 
To stop receiving notification emails like this one, please contact
harbs@apache.org.