-
Notifications
You must be signed in to change notification settings - Fork 566
/
xmlconfiguration.po
243 lines (222 loc) · 18.9 KB
/
xmlconfiguration.po
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# Language zh-CN translations for PACKAGE package.
# Automatically generated, 2010.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-06 14:46+0000\n"
"PO-Revision-Date: 2010-08-22 23:44+0830\n"
"Last-Translator: Strong Liu <stliu@hibernate.org>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: xmlconfiguration.xml:25
#, no-c-format
msgid "XML configuration"
msgstr "XML configuration"
#. Tag: filename
#: xmlconfiguration.xml:28
#, no-c-format
msgid "<filename>validation.xml</filename>"
msgstr "<filename>validation.xml</filename>"
#. Tag: para
#: xmlconfiguration.xml:30
#, no-c-format
msgid "The key to enable XML configuration for Hibernate Validator is the file <filename>validation.xml</filename>. If this file exists in the classpath its configuration will be applied when the <classname>ValidationFactory</classname> gets created. <xref linkend=\"image-validation-configuration\"/> shows a model view of the xsd <filename>valiation.xml</filename> has to adhere to."
msgstr "我们可以使用<filename>validation.xml</filename>来对Hibernate Validator进行配置. <classname>ValidationFactory</classname>在初始化的时候会在类路径下寻找此文件,如果找到的话,就会应用其中定义的配置信息. <xref linkend=\"image-validation-configuration\"/>显示了<filename>valiation.xml</filename>的xsd模型."
#. Tag: title
#: xmlconfiguration.xml:37
#, no-c-format
msgid "validation-configuration-1.0.xsd"
msgstr "validation-configuration-1.0.xsd"
#. Tag: para
#: xmlconfiguration.xml:52
#, no-c-format
msgid "shows the several configuration options of <filename>validation.xml</filename>."
msgstr "列出了<filename>validation.xml</filename>中的一些常用的配置项."
#. Tag: title
#: xmlconfiguration.xml:56
#, no-c-format
msgid "<title>validation.xml</title>"
msgstr "<title>validation.xml</title>"
#. Tag: programlisting
#: xmlconfiguration.xml:58
#, no-c-format
msgid ""
"<validation-config xmlns=\"http://jboss.org/xml/ns/javax/validation/configuration\"\n"
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
" xsi:schemaLocation=\"http://jboss.org/xml/ns/javax/validation/configuration\">\n"
" <default-provider>org.hibernate.validator.HibernateValidator</default-provider>\n"
" <message-interpolator>org.hibernate.validator.engine.ResourceBundleMessageInterpolator</message-interpolator>\n"
" <traversable-resolver>org.hibernate.validator.engine.resolver.DefaultTraversableResolver</traversable-resolver>\n"
" <constraint-validator-factory>org.hibernate.validator.engine.ConstraintValidatorFactoryImpl</constraint-validator-factory>\n"
" <constraint-mapping>/constraints-car.xml</constraint-mapping>\n"
" <property name=\"prop1\">value1</property>\n"
" <property name=\"prop2\">value2</property>\n"
"</validation-config>"
msgstr ""
"<validation-config xmlns=\"http://jboss.org/xml/ns/javax/validation/configuration\"\n"
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
" xsi:schemaLocation=\"http://jboss.org/xml/ns/javax/validation/configuration\">\n"
" <default-provider>org.hibernate.validator.HibernateValidator</default-provider>\n"
" <message-interpolator>org.hibernate.validator.engine.ResourceBundleMessageInterpolator</message-interpolator>\n"
" <traversable-resolver>org.hibernate.validator.engine.resolver.DefaultTraversableResolver</traversable-resolver>\n"
" <constraint-validator-factory>org.hibernate.validator.engine.ConstraintValidatorFactoryImpl</constraint-validator-factory>\n"
" <constraint-mapping>/constraints-car.xml</constraint-mapping>\n"
" <property name=\"prop1\">value1</property>\n"
" <property name=\"prop2\">value2</property>\n"
"</validation-config>"
#. Tag: para
#: xmlconfiguration.xml:62
#, no-c-format
msgid "There can only be one <filename>validation.xml</filename> in the classpath. If more than one is found an exception is thrown."
msgstr "类路径下面只能有一个<filename>validation.xml</filename>, 如果超过一个的话,会抛出异常."
#. Tag: para
#: xmlconfiguration.xml:66
#, no-c-format
msgid "All settings shown in the <filename>validation.xml</filename> are optional and in the case of <xref linkend=\"example-validation-xml\"/> show the defaults used within Hibernate Validator. The node <property>default-provider</property> allows to choose the Bean Validation provider. This is useful if there is more than one provider in the classpath. <property>message-interpolator</property>, <property>traversable-resolver</property> and <property>constraint-validator-factory</property> allow to customize the <classname>javax.validation.MessageInterpolator</classname>, <classname>javax.validation.TraversableResolver</classname> resp. <classname>javax.validation.ConstraintValidatorFactory</classname>. The same configuration options are also available programmatically through the <classname>javax.validation.Configuration</classname>. In fact XML configuration will be overridden by values explicitly specified via the API. It is even possible to ignore the XML configuration completely via <methodname> Configuration.ignoreXmlConfiguration()</methodname>. See also <xref linkend=\"validator-bootstrapping\"/>."
msgstr "<filename>validation.xml</filename>中所有的配置信息都是可选的, <xref linkend=\"example-validation-xml\"/>中就是列出了Hibernate Validator中的默认值. 如果类路径当中存在有多个Bean Validation的实现的话, 那么可以通过<property>default-provider</property>节点指定使用那个Bean Validation的实现. <property>message-interpolator</property>, <property>traversable-resolver</property> 和 <property>constraint-validator-factory</property>可以用来指定自定义的<classname>javax.validation.MessageInterpolator</classname>, <classname>javax.validation.TraversableResolver</classname>和<classname>javax.validation.ConstraintValidatorFactory</classname>. 同样的, 这些配置信息也可以通过编程的方式调用<classname>javax.validation.Configuration</classname>来实现. 另外, 你可以通过API的方式来重写xml中的配置信息, 也可以通过调用<methodname> Configuration.ignoreXmlConfiguration()</methodname>来完全的忽略掉xml的配置信息. 请参考<xref linkend=\"validator-bootstrapping\"/>."
#. Tag: para
#: xmlconfiguration.xml:84
#, no-c-format
msgid "Via the <property>constraint-mapping</property> you can list an arbitrary number of additional XML files containing the actual constraint configuration. See <xref linkend=\"section-mapping-constraints\"/>."
msgstr "你可以增加若干个<property>constraint-mapping</property>节点,在每个里面列出一个额外的xml文件用来定义约束规则, 具体请参考<xref linkend=\"section-mapping-constraints\"/>."
#. Tag: para
#: xmlconfiguration.xml:88
#, no-c-format
msgid "Last but not least, you can specify provider specific properties via the <property>property</property> nodes. Hibernate Validator does currently not make use of any custom properties."
msgstr "最后, 你可以通过<property>property</property>来定义各个Bean Validation 实现专属的属性. Hibernate Validator当前并没有使用任何特定的属性."
#. Tag: title
#: xmlconfiguration.xml:94
#, no-c-format
msgid "Mapping constraints"
msgstr "映射约束"
#. Tag: para
#: xmlconfiguration.xml:96
#, no-c-format
msgid "Expressing constraints in XML is possible via files adhering to the xsd seen in <xref linkend=\"image-mapping-configuration\"/>. Note that these mapping files are only processed if listed via <property>constraint-mapping</property> in your <filename>validation.xml</filename>."
msgstr "我们也可以通过xml来定义约束条件, 只需要这个xml符合<xref linkend=\"image-mapping-configuration\"/>中所定义的规范. 需要注意的是, 你必须把xml定义的约束列在<filename>validation.xml</filename>的<property>constraint-mapping</property>节点中才能得到处理."
#. Tag: title
#: xmlconfiguration.xml:103
#, no-c-format
msgid "validation-mapping-1.0.xsd"
msgstr "validation-mapping-1.0.xsd"
#. Tag: para
#: xmlconfiguration.xml:118
#, no-c-format
msgid "shows how our classes Car and RentalCar from <xref linkend=\"example-car\"/> resp. <xref linkend=\"example-rental-car\"/> could be mapped in XML."
msgstr "显示了如何通过xml定义的方式来给<xref linkend=\"example-car\"/>中的类Car 以及<xref linkend=\"example-rental-car\"/> 中的RentalCar定义约束条件."
#. Tag: title
#: xmlconfiguration.xml:123
#, no-c-format
msgid "constraints-car.xml"
msgstr "constraints-car.xml"
#. Tag: programlisting
#: xmlconfiguration.xml:125
#, no-c-format
msgid ""
"<constraint-mappings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
" xsi:schemaLocation=\"http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd\"\n"
" xmlns=\"http://jboss.org/xml/ns/javax/validation/mapping\">\n"
" <default-package>org.hibernate.validator.quickstart</default-package>\n"
" <bean class=\"Car\" ignore-annotations=\"true\">\n"
" <field name=\"manufacturer\">\n"
" <constraint annotation=\"javax.validation.constraints.NotNull\"/>\n"
" </field>\n"
" <field name=\"licensePlate\">\n"
" <constraint annotation=\"javax.validation.constraints.NotNull\"/>\n"
" </field>\n"
" <field name=\"seatCount\">\n"
" <constraint annotation=\"javax.validation.constraints.Min\">\n"
" <element name=\"value\">2</element>\n"
" </constraint>\n"
" </field>\n"
" <field name=\"driver\">\n"
" <valid/>\n"
" </field>\n"
" <getter name=\"passedVehicleInspection\" ignore-annotations=\"true\">\n"
" <constraint annotation=\"javax.validation.constraints.AssertTrue\">\n"
" <message>The car has to pass the vehicle inspection first</message>\n"
" <groups>\n"
" <value>CarChecks</value>\n"
" </groups>\n"
" <element name=\"max\">10</element>\n"
" </constraint>\n"
" </getter>\n"
" </bean>\n"
" <bean class=\"RentalCar\" ignore-annotations=\"true\">\n"
" <class ignore-annotations=\"true\">\n"
" <group-sequence>\n"
" <value>RentalCar</value>\n"
" <value>CarChecks</value>\n"
" </group-sequence>\n"
" </class>\n"
" </bean>\n"
" <constraint-definition annotation=\"org.mycompany.CheckCase\" include-existing-validator=\"false\">\n"
" <validated-by include-existing-validators=\"false\">\n"
" <value>org.mycompany.CheckCaseValidator</value>\n"
" </validated-by>\n"
" </constraint-definition>\n"
"</constraint-mappings>"
msgstr ""
"<constraint-mappings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
" xsi:schemaLocation=\"http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd\"\n"
" xmlns=\"http://jboss.org/xml/ns/javax/validation/mapping\">\n"
" <default-package>org.hibernate.validator.quickstart</default-package>\n"
" <bean class=\"Car\" ignore-annotations=\"true\">\n"
" <field name=\"manufacturer\">\n"
" <constraint annotation=\"javax.validation.constraints.NotNull\"/>\n"
" </field>\n"
" <field name=\"licensePlate\">\n"
" <constraint annotation=\"javax.validation.constraints.NotNull\"/>\n"
" </field>\n"
" <field name=\"seatCount\">\n"
" <constraint annotation=\"javax.validation.constraints.Min\">\n"
" <element name=\"value\">2</element>\n"
" </constraint>\n"
" </field>\n"
" <field name=\"driver\">\n"
" <valid/>\n"
" </field>\n"
" <getter name=\"passedVehicleInspection\" ignore-annotations=\"true\">\n"
" <constraint annotation=\"javax.validation.constraints.AssertTrue\">\n"
" <message>The car has to pass the vehicle inspection first</message>\n"
" <groups>\n"
" <value>CarChecks</value>\n"
" </groups>\n"
" <element name=\"max\">10</element>\n"
" </constraint>\n"
" </getter>\n"
" </bean>\n"
" <bean class=\"RentalCar\" ignore-annotations=\"true\">\n"
" <class ignore-annotations=\"true\">\n"
" <group-sequence>\n"
" <value>RentalCar</value>\n"
" <value>CarChecks</value>\n"
" </group-sequence>\n"
" </class>\n"
" </bean>\n"
" <constraint-definition annotation=\"org.mycompany.CheckCase\" include-existing-validator=\"false\">\n"
" <validated-by include-existing-validators=\"false\">\n"
" <value>org.mycompany.CheckCaseValidator</value>\n"
" </validated-by>\n"
" </constraint-definition>\n"
"</constraint-mappings>"
#. Tag: para
#: xmlconfiguration.xml:128
#, no-c-format
msgid "The XML configuration is closely mirroring the programmatic API. For this reason it should suffice to just add some comments. <property>default-package</property> is used for all fields where a classname is expected. If the specified class is not fully qualified the configured default package will be used. Every mapping file can then have several <property>bean</property> nodes, each describing the constraints on the entity with the specified class name.<warning> <para>A given entity can only be configured once across all configuration files. If the same class is configured more than once an exception is thrown.</para> </warning>Settings <property>ignore-annotations</property> to true means that constraint annotations placed on the configured bean are ignored. The default for this value is <constant>true</constant>. ignore-annotations is also available for the nodes <property>class</property>, <property>fields</property> and <property>getter</property>. If not explicitly specified on these levels the configured <property>bean</property> value applies. Otherwise do the nodes <property>class</property>, <property>fields</property> and <property>getter</property> determine on which level the constraints are placed (see <xref linkend=\"validator-usingvalidator-annotate\"/>). The <property>constraint</property> node is then used to add a constraint on the corresponding level. Each constraint definition must define the class via the annotation attribute. The constraint attributes required by the Bean Validation specification (<property>message</property>, <property>groups</property> and <property>payload</property>) have dedicated nodes. All other constraint specific attributes are configured using the the <property>element</property> node."
msgstr "这个xml的定义基本上和通过编程方式差不多, 所以只需要简单的解释. 其中<property>default-package</property>属性用来定义一个默认的包路径, 如果下面指定的class不是全限定名称的话,会自动加上这个默认的包路径. 每个xml文件都可以包含任意多个<property>bean</property>节点, 每个对应一个要添加约束条件的实体类.<warning> <para>每个实体类只能在所有的xml映射文件中被定义一次, 否则会抛出异常.</para> </warning> 通过添加<property>ignore-annotations</property> 属性并将其设置为<constant>true</constant>可以忽略在对应<property>bean</property>上添加的约束标注信息, 这个属性的默认值就是<constant>true</constant>. <property>ignore-annotations</property> 属性还可以定义在<property>class</property>, <property>fields</property> 和 <property>getter</property>属性上, 如果没有明确指定的话, 那么默认级别是<property>bean</property> (可参考 <xref linkend=\"validator-usingvalidator-annotate\"/>). <property>constraint</property> 节点用于添加一个约束条件到其父节点对应的元素上, 并且它需要通过<property>annotation</property>属性来指定需要使用哪个约束条件. 对于每个约束条件中所需要的属性, 其中, 由Bean Validation 规范规定的属性(<property>message</property>, <property>groups</property> 和 <property>payload</property>) 可以通过同名的子节点来定义, 而每个约束条件中自定义的属性, 则需要使用<property>element</property>节点来定义."
#. Tag: para
#: xmlconfiguration.xml:156
#, no-c-format
msgid "The class node also allows to reconfigure the default group sequence (see <xref linkend=\"section-default-group-class\"/>) via the <property>group-sequence</property> node."
msgstr "<property>class</property>节点同样支持通过<property>group-sequence</property>节点来对一个类的默认校验组进行重定义(请参考 <xref linkend=\"section-default-group-class\"/>) ."
#. Tag: para
#: xmlconfiguration.xml:160
#, no-c-format
msgid "Last but not least, the list of <classname>ConstraintValidator</classname>s associated to a given constraint can be altered via the <property>constraint-definition</property> node. The <property>annotation</property> attribute represents the constraint annotation being altered. The <property>validated-by</property> elements represent the (ordered) list of <classname>ConstraintValidator</classname> implementations associated to the constraint. If <property>include-existing-validator</property> is set to <constant>false</constant>, validators defined on the constraint annotation are ignored. If set to <constant>true</constant>, the list of ConstraintValidators described in XML are concatenated to the list of validators described on the annotation."
msgstr "最后, 你还可以通过<property>constraint-definition</property>节点来对一个指定的约束条件上绑定的校验器(<classname>ConstraintValidator</classname>)进行修改. 此节点上的<property>annotation</property>对应要修改的约束条件, 而<property>validated-by</property>子节点中(按顺序)列出要关联到此约束条件上的校验器( <classname>ConstraintValidator</classname>的实现类), 而<property>include-existing-validator</property>属性如果是<constant>false</constant>的话,那么默认定义在此约束条件上的校验器将被忽略, 如果为<constant>true</constant>, 那么在xml中定义的校验器会被添加在约束条件上默认定义的校验器的后面."