{"id":42,"date":"2005-11-24T19:07:55","date_gmt":"2005-11-25T00:07:55","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/?p=42"},"modified":"2005-11-24T19:07:55","modified_gmt":"2005-11-25T00:07:55","slug":"cdata-with-xslt","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2005\/11\/24\/cdata-with-xslt\/","title":{"rendered":"CDATA With XSLT"},"content":{"rendered":"<p>In an XML file you can use CDATA to tell the parser that anything inside the CDATA element is your text data and not XML formatting. In a sense, you can use CDATA to escape data that looks like XML.  See <a href=\"http:\/\/www.juixe.com\/techknow\/index.php\/2005\/09\/10\/escape-from-xml\" title=\"Escape From XML\">Escape From XML<\/a>.  For example, you can escape the ampersand like this:<\/p>\n<pre>\n&amp;#38;\n<\/pre>\n<p>or by using CDATA as in:<\/p>\n<pre>\n&lt;![CDATA[ & ]]&gt;\n<\/pre>\n<p>I often work with XML and XSLT so when I want to treat a block of HTML as data I use the CDATA element in my XML file that will later be transformed with an XSL.  For example, in my XML I might have something like this:<\/p>\n<pre>\n&lt;![CDATA[\n   &lt;b&gt;this is bold&lt;\/b&gt;\n]]&gt;\n<\/pre>\n<p>In my XSL file, I need to disable the data from being escaped by using the disable-output-escaping of the xsl:value-of tag as in:<\/p>\n<pre>\n&lt;xsl:value-of\n   select=&quot;.&quot;\n   disable-output-escaping=&quot;yes&quot;\/&gt;\n<\/pre>\n<p>If you forget the disable-output-escaping attribute the contents of the CDATA will be escaped, for example &lt; will be transformed to &amp;lt;.  With the disable-output-escaping attribute set to yes, the contents from the CDATA will not be escaped and treated as is.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In an XML file you can use CDATA to tell the parser that anything inside the CDATA element is your text data and not XML formatting. In a sense, you can use CDATA to escape data that looks like XML. See Escape From XML. For example, you can escape the ampersand like this: &amp;#38; or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[13,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-G","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/42"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}