簡體   English   中英

如何使用外部 xsd 和 Saxon-HE java 驗證 xml

[英]How to validate xml using external xsd with Saxon-HE java

我正在使用 Saxon-HE (11.3) 使用外部 xsd 驗證 xml。 但是我得到了 nullpointerexception,因為 schemaManager 是 null。

Processor processor = new Processor (false); SchemaManager manager = processor.getSchemaManager(); manager.load(new StreamSource("xsdFile));

在第三行獲得 NPE。 我不明白為什么 schemaManager 總是 null? 我試圖設置 new Processor(true) 但它不起作用。

撒克遜文檔解釋說

  1. new Processor(false)創建非模式感知配置

  2. new Processor(true)啟用需要許可證密鑰的模式處理等功能

  3. 使用非模式感知配置, processor.getSchemaManager()返回 null。

可能不是 API 設計中最優雅的部分,但該產品正在按照文檔中的說明進行操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM