2016-04-13 2 views
1

Ich erzeuge XML innerhalb JSP-Seite, in der ich einen CDATA-Abschnitt verwende. Das Problem besteht darin, dass der einzelne CDATA-Abschnitt in mehrere CDATAs konvertiert wird. Hier ist mein Code:JSP Mehrere CDATA-Abschnitte, wenn ich brauche 1

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><?xml version="1.0" encoding="UTF-8"?> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ page contentType="text/xml;charset=UTF-8" language="java" %> 
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/"> 

    <channel> 
     <title>My Website</title> 
     <link>http://www.mywebsite.zz/</link> 
     <description> 
      Sample description 
     </description> 
     <language>en-us</language> 
     <item> 
       <title>${item.title}</title> 
       <link>${storyLink}</link> 
       <guid isPermaLink="true">${storyLink}</guid> 
       <pubDate><fmt:formatDate type="both" 
         timeZone="UTC" 
         pattern="yyyy-MM-dd'T'HH:mm:ssz" 
         dateStyle="short" timeStyle="short" 
         value="${item.createdTime}" /> 
       </pubDate> 
       <description> 
        ${item.description} 
       </description> 
       <content:encoded> 
        <![CDATA[ 
         <!doctype html> 
          <html lang="en" prefix="op: http://media.facebook.com/op#"> 
          <head> 
           <meta charset="utf-8"> 
           <link rel="canonical" href="${storyLink}"> 
           <meta property="op:markup_version" content="v1.0"> 
         <body> 
           <article> 
           <header> 
            <h1>${item.title}</h1> 
           </header> 
           ${item.post} 
           </article> 
         </body> 
        ]]> 
       </content:encoded> 

      </item> 
    </channel> 
</rss> 

Hier ist die Antwort, die ich erhalten:

<rss xmlns:content="http://purl.org/rss/1.0/modules/content/"> 
    <channel> 
    <title>Carbonated</title> 
    <link>http://www.mywebsite.zz/</link> 
    <description>Sample description</description> 
    <language>en-us</language> 
    <item> 
     <title> 
     My Title 
     </title> 
     <link> 
     http://localhost/mypost 
     </link> 
     <guid isPermaLink="true"> 
     http://localhost/mypost 
     </guid> 
     <pubDate>2016-04-06T10:51:48UTC</pubDate> 
     <description> 
     This is a description 
     </description> 
     <content:encoded> 
     <![CDATA[ 
      <!doctype html> 
      <html lang="en" prefix="op: http://media.facebook.com/op#"> 
      <head> 
      <meta charset="utf-8"> 
      <link rel="canonical" href="ht 
     ]]> 
     <![CDATA[ 
      tp://localhost/mypost"> 
      <meta property="op:markup_version" content="v1.0"> 
      </head> 
     <body> 
      <article> 
      <header> 
       <h1>Heading</h1> 
      </header> 
      <p>topic post</p> 
      </article> 
     </body> 
     ]]> 
    </content:encoded> 
    </item> 

sehen, dass die einzelnen CDATA-Abschnitt in mehrere Abschnitte umgewandelt wird. Ich möchte nicht, dass das passiert.

Antwort

1

Mein Bad. Es war nur die Art und Weise, wie Chrome XML anzeigt. Ich schaue in Quellcode und öffne die Seite mit Firefox und Font, es war nur 1 CDATA Abschnitt wie erwartet.

Verwandte Themen