Are XHTML object encodings valid in XML documents if they are contained within CDATA tags?

Is this a valid (well-formed) XML document?

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner>&copy;</inner>
</outer>

The question is, is HTML / XHTML "& copy;" the coding entity is valid in an XML document where there is no DTD or schema to define it. An alternative way to express what was said would be to say the following:

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner>&#169;</inner>
</outer>

This would seem to be valid XML with UTF-8 encoding.

But is it really:

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner><![CDATA[&copy;]]></inner>
</outer>

The author of the above intends to tell the XML parser that it must go through the copyright symbol above as the string "& copy;" and not as your own Unicode character.

: " XML- CDATA, , -" " . [] - , , CDATA ." ( Wikipedia)

XML , CDATA, , , .

, XML CDATA.

!

+3
3

CDATA , , XML. , - - XML. , CDATA, XML CDATA; , XML, , .

, , : , :

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner><![CDATA[&copy;]]></inner>
</outer>

inner - &copy;, XML . :

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner><![CDATA[<normally> this looks <like/> &amp; xml </normally>]]></inner>
</outer>

inner

<normally> this looks <like/> &amp; xml </normally>

CDATA:

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner>&lt;normally&gt; this looks &lt;like/&gt; &amp;amp; xml &lt;/normally&gt;</inner>
</outer>

, XML. (, inner DTD , XML), XML- :

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner><normally> this looks <like/> &amp; xml </normally></inner>
</outer>

CDATA XML, XML- inner, XML.

. , - XML, DTD , inner xsd: string , XML-.

, HTML XHTML, XML, XML, . XML- .

+7

, , , -, .

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner>&copy;></inner>
</outer>

( "" , "lt", "gt" "quot" XML).

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner>&#169;</inner>
</outer>

, , , ( ).

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner><![CDATA[&copy;]]></inner>
</outer>

, ( <inner> Unicode, ).

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE outer[
<!ENTITY copy "&#169;">
]>
<outer>
  <inner>&copy;></inner>
</outer>

, . , , /.

<?xml version="1.0" encoding="UTF-8" ?> 
<outer>
  <inner>©</inner>
</outer>

( = "UTF-8", = "US-ASCII", ), . / .

+5

CDATA XML, , , CDATA.

, , CDATA , , & copy; XML . , CDATA X/HTML, , blob base64 . XML CDATA; "foo", &copy;.

.

+1

Source: https://habr.com/ru/post/1705075/


All Articles