0
일부 XML 노드에 일부 HTML을 포함해야하며 소비자는이를 CDATA 섹션 내부에 넣기를 원합니다. 그들은 CDATA가 <![CDATA[ ]]>.
으로 보존되기를 원합니다. 그러나 여는 괄호와 여는 괄호는 이스케이프되므로 <![CDATA[]]>
대신이 괄호를받습니다. 여러 가지 방법을 시도했지만 아무 것도 효과가없는 것 같습니다. 그리고 Restlet 프레임 워크에 내장 된 기능이없는 것 같습니다. 다른 누구도이 문제에 직면 해 해결책을 찾았습니까? 다음은 내 코드 샘플입니다.SAX를 사용하여 Restlet 웹 서비스가 생성 한 XML에 CDATA 섹션 삽입
@Get
public Representation toXml() {
// Create a new SAX representation
SaxRepresentation result = new SaxRepresentation() {
public void write(org.restlet.ext.xml.XmlWriter writer)
throws IOException {
...
try {
// Start document
writer.startDocument();
// Append the root node
writer.startElement(COMPANIES);
// I want to start the CDATA section here.
writer.startElement(BRANCHES);
if((mfgRepList != null) && (mfgRepList.size() > 0)){
writer = MfgRep.getMfgRepHtml(writer, mfgRepList);
}
writer.endElement(BRANCHES);
// I want to end the CDATA section here.
writer.endElement(COMPANIES);
writer.endDocument();
} catch (SAXException e) {
throw new IOException(e.getMessage());
}
}; // end of write
}; // end of create new Sax representation
return result;
}
브라보, 그래디! 그것은 트릭을했다. 당신의 노력에 정말 감사드립니다. Stackoverflow 다시 한 번 통해 온다. 이것은 지구상에서 가장 위대한 두뇌 트러스트 중 하나입니다. –