为什么我们在Hibernate配置或映射文件中编写标记

时间:2018-05-06 16:32:04

标签: java xml hibernate xsd dtd

要验证xml,我们需要dtd或xsd。如果我们想要针对dtd验证xml,那么我们需要编写这个。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">

当我们的dtd存在于文件系统中时使用SYSTEM,如果我们的dtd存在于某个网络中,则使用PUBLIC。在这种情况下,如果我们正在写这个     

"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd"
意味着我们的dtd存在于具有此地址的网络中,我们的hibernate-configuration xml文件将针对此dtd进行验证。

但为什么要写这个???????

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

所以请回答我的问题。

2 个答案:

答案 0 :(得分:1)

The value axios in the DOCTYPE is the Formal Public Identifier. It uniquely identifies the <!-- the submit event will no longer reload the page --> <form v-on:submit.prevent="onSubmit"></form> external entity, and may be used to resolve a URI reference.

In addition to a system identifier, an external identifier may include a public identifier.

An XML processor attempting to retrieve the entity's content may use any combination of the public and system identifiers as well as additional information outside the scope of this specification to try to generate an alternative URI reference. If the processor is unable to do so, it must use the URI reference specified in the system literal. Before a match is attempted, all strings of white space in the public identifier must be normalized to single space characters (#x20), and leading and trailing white space must be removed.

Also, a good reference explaining the components of the FPI: https://www.quackit.com/xml/tutorial/dtd_fpi.cfm

Here's a real life example of an FPI. In this case, the DTD was created by the W3C for XHTML:

-//Hibernate/Hibernate Configuration DTD 3.0//EN

An FPI is made up of 4 fields, each separated by double forward slashes (PUBLIC):

  1. -//W3C//DTD XHTML 1.0 Transitional//EN Indicates whether the DTD is connected to a formal standard or not. If the DTD hasn't been approved (for example, you've defined the DTD yourself), use a hypen (-). If the DTD has been approved by a nonstandards body, use a plus sign "+". If the DTD has been approved by a formal standards body this field should be a reference to the standard itself.

  2. // Holds the name of the group (or person) responsible for the DTD. The above example is maintained by the W3C, so "W3C" appears in the second field.

  3. - Indicates the type of document that is being described. This usually contains some form of unique identifier (such as a version number).

  4. W3C Specifies the language that the DTD uses. This is achieved by using the two letter identifier for the language (i.e. for english, use "EN").

答案 1 :(得分:0)

A Doctype describes which DTD/XSD the XML file follows.

It indicates what elements are allowed inside what other elements (for the purpose of validation).

It also decides what named character references are available (beyond the 5 XML built-ins of function load_playlist(link){ audio = $('audio'); audio[0].src=link; audio[0].load(); audio[0].play(); } , import pandas as pd one = pd.read_csv("~/Documents/2017Data/2017DATA.csv", encoding = "ISO-8859-1") , &amp;, &lt; and &gt;)