Xerces2-j XMLInputSource以及 SAX InputSource指的是公共和系統識別符號。Xerces2-JXMLInputSource也指基本系統識別符號。
這些識別符號代表什么?
編輯:Xerces-J,當將檔案位置作為 SystemId 時,將打開檔案作為輸入。如果輸入是作為位元組流提供的,而不是從其他來源(例如資料庫)提供,那么公共 ID 或系統 ID 有什么用途嗎?
uj5u.com熱心網友回復:
如果您查看 XML 語法,您會看到,例如,外部物體參考使用以下語法:
ExternalID ::= 'SYSTEM' S SystemLiteral
| 'PUBLIC' S PubidLiteral S SystemLiteral
以下是使用此語法的示例:
<!ENTITY open-hatch
PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
"http://www.textuality.com/boilerplate/OpenHatch.xml">
對 DTD 的參考以相同的方式作業(實際上,外部 DTD 從技術上講是一種物體)。
“系統識別符號”是一個 URI,用于標識可以在何處找到物體的文本。“公共識別符號”(SGML 的遺留物)更像是資源的名稱;如果您有某種索引或目錄可以告訴您在哪里查找,它只會幫助您找到資源。
系統識別符號通常作為相對 URI 參考(例如“books.dtd”)給出,需要相對于基本 URI 進行決議。基本 URI 通常是找到包含資源(或物體)的位置。例如,如果一個 XML 檔案是 at,http://my.com/lib/books.xml那么它的基本 URI 是,然后http://my.com/lib/相對 URIbooks.dtd擴展為http://my.com/lib/books.dtd.
在回答您的問題“公眾或系統 ID 是否有任何目的”時,如果檔案完全由單個物體組成(通常是這種情況),答案是否定的。但是一旦多個物體開始發揮作用,您就需要識別符號將它們鏈接在一起。
uj5u.com熱心網友回復:
如果輸入是作為位元組流提供的,而不是從其他來源(例如資料庫)提供,那么公共 ID 或系統 ID 有什么用途嗎?
不,因為如果輸入是位元組流,則無需決議物體的位置。
這些識別符號代表什么?
我認為這個執行緒解釋得很好:
SYSTEM declaration can be used to specify a file on the local file
system like:
<!DOCTYPE RootElement SYSTEM "C:\validate.dtd">
The problem with this approach is that if the file is made public the
path specified on the local file system will not have any meaning any
more. Even if the path specified in the SYSTEM declaration *is* a URL:
<!DOCTYPE RootElement SYSTEM "http://www.mihaiu.name/validate.dtd">
the parser might be unable to retrieve the DTD file if the system is
not connected to the Internet.
The PUBLIC declaration constitutes a partial solution to this problem.
The string contained in a PUBLIC declaration is not an URL but an URN
(Uniform Resource Name). A URN does not pinpoint the precise location
of the resource, but only clearly specify its name. The *parser* of the
document must be smart enough to be able to generate a URL from a URN
using some internal logic.
Example of a PUBLIC declaration:
<!DOCTYPE RootElement PUBLIC "mihaiu/validate.dtd"
SYSTEM "http://www.mihaiu.name/validate.dtd">
In this case, a custom parser that already has a catalogue of DTDs
published by mihaiu can generate a URL from the PUBLIC declaration. The
generated URL can look like
c:\DTDs\validate.dtd
There is no standard way to convert a URN to a URL, so, if this
conversion fails because the parser does not contain the internal logic
to perform such a conversion (or for whatever other reason) the parser
will attempt to use the SYSTEM declaration which in this case resolves
to
http://www.mihaiu.name/validate.dtd
Important observation:
Since there is no standard way to generate a URL from a URN the PUBLIC
declarations can only be useful for customized parsers !!! (e.g. they
are not useful for general purpose parsers like Xerces)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/411825.html
標籤:
