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

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

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

問題描述

我正在嘗試解析包含符合 XML 1.1 規(guī)范的 XML 內(nèi)容的字符串.XML 包含在 XML 1.0 規(guī)范中不允許但在 XML 1.1 規(guī)范中允許的字符引用(字符引用轉(zhuǎn)換為 U+0001–U+001F 范圍內(nèi)的 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).

根據(jù) Xerces2 網(wǎng)站,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
    }
}

我已嘗試設(shè)置 XML 標(biāo)頭以指示 XML 符合 1.1 規(guī)范...

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(仍會(huì)生成無效字符引用異常).

...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 個(gè)功能是您必須打開的.

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:執(zhí)行 Unicode 規(guī)范化檢查(如 XML 1.1 建議的第 2.13 節(jié)和附錄 B 中所述)并報(bào)告規(guī)范化錯(cuò)誤.

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:不報(bào)告 Unicode 規(guī)范化錯(cuò)誤.

False: Do not report Unicode normalization errors.

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

正確:解析器同時(shí)支持 XML 1.0 和 XML 1.1.
False:解析器僅支持 XML 1.0.
訪問:只讀自:Xerces-J 2.7.0注意:此功能的價(jià)值取決于 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.

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

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

相關(guān)文檔推薦

Upload progress listener not fired (Google drive API)(上傳進(jìn)度偵聽器未觸發(fā)(Google 驅(qū)動(dòng)器 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(谷歌驅(qū)動(dòng)api服務(wù)賬戶查看上傳文件到谷歌驅(qū)動(dòng)使用java)
Google Drive service account returns 403 usageLimits(Google Drive 服務(wù)帳號(hào)返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例中缺少)
主站蜘蛛池模板: 日本精品一区二区在线观看 | 成av在线 | 中文字幕观看 | 青青草华人在线视频 | 欧美极品在线视频 | 国产成人精品免高潮在线观看 | 天天干天天草 | 天天干天天色 | 亚洲精品一二区 | 国产色爽| 国产乱码精品一区二区三区中文 | 中文字幕一区二区三区精彩视频 | 欧美啊v在线观看 | 国产精品国产三级国产aⅴ中文 | 国产一区二区三区免费观看在线 | 日本午夜一区二区三区 | 中文精品久久 | 欧美一二区 | 免费影视在线观看 | 色欧美片视频在线观看 | 亚洲福利在线观看 | 草草在线观看 | 亚洲精品一区二区三区在线观看 | 99pao成人国产永久免费视频 | 一级a性色生活片久久毛片波多野 | 国产精品久久久久久久久久三级 | 欧美一级淫片007 | av看片| 亚洲人成网站777色婷婷 | 精品麻豆剧传媒av国产九九九 | 久久久夜色精品亚洲 | 成人精品一区 | 午夜免费福利电影 | 99久久精品免费看国产免费软件 | 欧美一区二区网站 | 国产中文| 综合网中文字幕 | 午夜免费网站 | 狠狠操电影| 亚洲精品福利在线 | 久久一二 |