久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 Java 和 Xerces 解析符合 1.1 規范的 XML?

How can I parse XML that confirms to the 1.1 spec using Java and Xerces?(如何使用 Java 和 Xerces 解析符合 1.1 規范的 XML?)
本文介紹了如何使用 Java 和 Xerces 解析符合 1.1 規范的 XML?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試解析包含符合 XML 1.1 規范的 XML 內容的字符串.XML 包含在 XML 1.0 規范中不允許但在 XML 1.1 規范中允許的字符引用(字符引用轉換為 U+0001–U+001F 范圍內的 Unicode 字符).

I'm trying to parse a String which contains XML content which conforms to the XML 1.1 spec. The XML contains character references which are not allowed in the XML 1.0 spec but which are allowed in the XML 1.1 spec (character references which translate to Unicode characters in the range U+0001–U+001F).

根據 Xerces2 網站,Xerces2 解析器支持解析 XML 1.1 文檔.但是,我不知道如何告訴它我們嘗試解析的 XML 包含符合 1.1 的 XML.

According the Xerces2 website, the Xerces2 parser supports parsing XML 1.1 documents. However, I cannot figure out how to tell it the XML we are trying to parse contains 1.1-compliant XML.

我正在使用 DocumentBuilder 來解析 XML(類似這樣):

I'm using a DocumentBuilder to parse the XML (something like this):

public Element parseString(String xmlString) {
    try {
          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
          DocumentBuilder documentBuilder = dbf.newDocumentBuilder();

          InputSource source = new InputSource(new StringReader(xmlString));

      // Throws org.xml.sax.SAXParseException becuase of the invalid character refs
          Document doc = documentBuilder.parse(source);

          return doc.getDocumentElement();

    } catch (ParserConfigurationException pce) {
          // Handle the error
    } catch (SAXException se) {
          // Handle the error
    } catch (IOException ioe) {
          // Handle the error
    }
}

我已嘗試設置 XML 標頭以指示 XML 符合 1.1 規范...

I've tried setting the XML header to indicate the XML conforms to the 1.1 spec...

xmlString = "<?xml version="1.1" encoding="UTF-8" ?>" + xmlString;

...但仍被解析為 1.0 XML(仍會生成無效字符引用異常).

...but it is still parsed as 1.0 XML (still generates the invalid character reference exceptions).

如何配置 Xerces 解析器以將 XML 解析為 XML 1.1?是否有其他解析器可以為 XML 1.1 提供更好的支持?

How can I configure the Xerces parser to parse the XML as XML 1.1? Is there an alternative parser which provides better support for XML 1.1?

推薦答案

看這里 查看 xerces 支持的所有功能的列表.可能低于 2 個功能是您必須打開的.

See here for a list of all the features supported by xerces. May be below 2 features is what you have to turn on.

http://xml.org/sax/features/unicode-normalization-checking

True:執行 Unicode 規范化檢查(如 XML 1.1 建議的第 2.13 節和附錄 B 中所述)并報告規范化錯誤.

True: Perform Unicode normalization checking (as described in section 2.13 and Appendix B of the XML 1.1 Recommendation) and report normalization errors.

False:不報告 Unicode 規范化錯誤.

False: Do not report Unicode normalization errors.

http://xml.org/sax/features/xml-1.1

正確:解析器同時支持 XML 1.0 和 XML 1.1.
False:解析器僅支持 XML 1.0.
訪問:只讀自:Xerces-J 2.7.0注意:此功能的價值取決于 SAX 解析器擁有的解析器配置是否已知支持 XML 1.1.

True: The parser supports both XML 1.0 and XML 1.1.
False: The parser supports only XML 1.0.
Access: read-only Since: Xerces-J 2.7.0 Note: The value of this feature will depend on whether the parser configuration owned by the SAX parser is known to support XML 1.1.

這篇關于如何使用 Java 和 Xerces 解析符合 1.1 規范的 XML?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Upload progress listener not fired (Google drive API)(上傳進度偵聽器未觸發(Google 驅動器 API))
Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 將文件保存在特定文件夾中)
Google Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 無效的 DriveId 和 Null ResourceId)
Google drive api services account view uploaded files to google drive using java(谷歌驅動api服務賬戶查看上傳文件到谷歌驅動使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務帳號返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 欧美在线一区二区三区 | 91国产在线播放 | 亚洲成人毛片 | 午夜影院在线观看版 | 曰韩一二三区 | 久久影音先锋 | 欧美一区二区三区四区在线 | 亚洲视频免费在线看 | 久久综合久色欧美综合狠狠 | 福利片在线观看 | 国产综合久久久 | 国产情侣激情 | av电影手机在线看 | 亚洲三级在线观看 | 在线观看国产wwwa级羞羞视频 | 国产精彩视频 | 殴美黄色录像 | 国产精品一区二区久久久久 | 欧美激情精品久久久久久免费 | 欧美一级特黄aaa大片在线观看 | 久久精品天堂 | 网站黄色av | 久草新在线 | 亚洲97 | 欧美久久久久久久久 | 一级黄色大片 | 精品国产一区二区久久 | 91国内精精品久久久久久婷婷 | 国产精品视频偷伦精品视频 | 九九在线视频 | 成人午夜影院 | 欧美精品导航 | 日韩色综合 | 日韩在线一区二区 | 国产在线小视频 | 一区二区免费看 | 亚洲国产一区在线 | 精品一区二区三区入口 | 在线日韩中文字幕 | 日日日日日日bbbbb视频 | 日本欧美国产在线观看 |