2008年4月17日星期四

2008年4月16日星期三

XML process Tips

1. how to determine the character encoding of a feed

这个功能由com.sun.syndication.io.XmlReader完成

http://wiki.java.net/bin/view/Javawsxml/Rome05CharsetEncoding

http://diveintomark.org/archives/2004/02/13/xml-media-types



2. what is xml BOM?

字符编码详解:http://blog.csdn.net/hillMover/archive/2005/10/06/496093.aspx



3. rome在处理feed的时候,将html的特殊字符,转换成了xml entity。

 
这个功能是由com.sun.syndication.io.impl.XmlFixerReader完成的,其中定义了一个map,作为映射。

 
CODED_ENTITIES.put(" ",  " ");

 
CODED_ENTITIES.put("¡", "¡");

 
.........



4.

在使用Jdom,把xml输出为String的过程中,需要定义processing instruction to disable output escaping.

org.jdom.output.XMLOutputter.printProcessingInstruction



// IMPORTANT!! set processing instruction to disable output escaping

ProcessingInstruction pi = new ProcessingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "data");

root.addContent(0, pi);



5. 最后,实现一个方法,将xml entities map to html。

  
就是将rome的功能倒过来。