|
47 | 47 | import org.w3c.dom.Node;
|
48 | 48 |
|
49 | 49 | import javax.annotation.Nullable;
|
50 |
| -import javax.xml.XMLConstants; |
51 | 50 | import javax.xml.stream.XMLEventReader;
|
52 | 51 | import javax.xml.stream.XMLInputFactory;
|
53 | 52 | import javax.xml.stream.XMLStreamConstants;
|
@@ -166,7 +165,7 @@ private Map<QName, XdmValue> readParamsMap(final Optional<MapType> option, final
|
166 | 165 | } catch (final XPathException e) {
|
167 | 166 | throw new XPathException(fnTransform, ErrorCodes.FOXT0002, "Supplied xslt-version is not a valid xs:decimal: " + e.getMessage(), explicitXsltVersion.get(), e);
|
168 | 167 | }
|
169 |
| - if (xsltVersion != v1_0 && xsltVersion != v2_0 && xsltVersion != v3_0) { |
| 168 | + if (xsltVersion != V1_0 && xsltVersion != V2_0 && xsltVersion != V3_0) { |
170 | 169 | throw new XPathException(fnTransform, ErrorCodes.FOXT0001, "Supplied xslt-version is an unknown XSLT version: " + explicitXsltVersion.get());
|
171 | 170 | }
|
172 | 171 | } else {
|
@@ -290,72 +289,72 @@ private void validateRequestedProperties(final MapType requestedProperties) thro
|
290 | 289 | }
|
291 | 290 | }
|
292 | 291 | private static final Option<StringValue> BASE_OUTPUT_URI = new ItemOption<>(
|
293 |
| - Type.STRING, "base-output-uri", v1_0, v2_0, v3_0); |
| 292 | + Type.STRING, "base-output-uri", V1_0, V2_0, V3_0); |
294 | 293 | private static final Option<BooleanValue> CACHE = new ItemOption<>(
|
295 |
| - Type.BOOLEAN, "cache", BooleanValue.TRUE, v1_0, v2_0, v3_0); |
| 294 | + Type.BOOLEAN, "cache", BooleanValue.TRUE, V1_0, V2_0, V3_0); |
296 | 295 | private static final Option<StringValue> DELIVERY_FORMAT = new ItemOption<>(
|
297 |
| - Type.STRING, "delivery-format", new StringValue("document"), v1_0, v2_0, v3_0); |
| 296 | + Type.STRING, "delivery-format", new StringValue("document"), V1_0, V2_0, V3_0); |
298 | 297 | private static final Option<BooleanValue> ENABLE_ASSERTIONS = new ItemOption<>(
|
299 |
| - Type.BOOLEAN, "enable-assertions", BooleanValue.FALSE, v3_0); |
| 298 | + Type.BOOLEAN, "enable-assertions", BooleanValue.FALSE, V3_0); |
300 | 299 | private static final Option<BooleanValue> ENABLE_MESSAGES = new ItemOption<>(
|
301 |
| - Type.BOOLEAN, "enable-messages", BooleanValue.TRUE, v1_0, v2_0, v3_0); |
| 300 | + Type.BOOLEAN, "enable-messages", BooleanValue.TRUE, V1_0, V2_0, V3_0); |
302 | 301 | private static final Option<BooleanValue> ENABLE_TRACE = new ItemOption<>(
|
303 |
| - Type.BOOLEAN, "enable-trace", BooleanValue.TRUE, v2_0, v3_0); |
| 302 | + Type.BOOLEAN, "enable-trace", BooleanValue.TRUE, V2_0, V3_0); |
304 | 303 | private static final Option<ArrayType> FUNCTION_PARAMS = new ItemOption<>(
|
305 |
| - Type.ARRAY,"function-params", v3_0); |
| 304 | + Type.ARRAY,"function-params", V3_0); |
306 | 305 | private static final Option<Item> GLOBAL_CONTEXT_ITEM = new ItemOption<>(
|
307 |
| - Type.ITEM, "global-context-item", v3_0); |
| 306 | + Type.ITEM, "global-context-item", V3_0); |
308 | 307 | static final Option<QNameValue> INITIAL_FUNCTION = new ItemOption<>(
|
309 |
| - Type.QNAME,"initial-function", v3_0); |
| 308 | + Type.QNAME,"initial-function", V3_0); |
310 | 309 | static final Option<Sequence> INITIAL_MATCH_SELECTION = new SequenceOption<>(
|
311 |
| - Type.ATOMIC,Type.NODE, "initial-match-selection", v3_0); |
| 310 | + Type.ATOMIC,Type.NODE, "initial-match-selection", V3_0); |
312 | 311 | static final Option<QNameValue> INITIAL_MODE = new ItemOption<>(
|
313 |
| - Type.QNAME,"initial-mode", v1_0, v2_0, v3_0); |
| 312 | + Type.QNAME,"initial-mode", V1_0, V2_0, V3_0); |
314 | 313 | static final Option<QNameValue> INITIAL_TEMPLATE = new ItemOption<>(
|
315 |
| - Type.QNAME,"initial-template", v2_0, v3_0); |
| 314 | + Type.QNAME,"initial-template", V2_0, V3_0); |
316 | 315 | private static final Option<StringValue> PACKAGE_NAME = new ItemOption<>(
|
317 |
| - Type.STRING,"package-name", v3_0); |
| 316 | + Type.STRING,"package-name", V3_0); |
318 | 317 | private static final Option<StringValue> PACKAGE_LOCATION = new ItemOption<>(
|
319 |
| - Type.STRING,"package-location", v3_0); |
| 318 | + Type.STRING,"package-location", V3_0); |
320 | 319 | private static final Option<NodeValue> PACKAGE_NODE = new ItemOption<>(
|
321 |
| - Type.NODE,"package-node", v3_0); |
| 320 | + Type.NODE,"package-node", V3_0); |
322 | 321 | private static final Option<StringValue> PACKAGE_TEXT = new ItemOption<>(
|
323 |
| - Type.STRING,"package-text", v3_0); |
| 322 | + Type.STRING,"package-text", V3_0); |
324 | 323 | private static final Option<StringValue> PACKAGE_VERSION = new ItemOption<>(
|
325 |
| - Type.STRING,"package-version", new StringValue("*"), v3_0); |
| 324 | + Type.STRING,"package-version", new StringValue("*"), V3_0); |
326 | 325 | private static final Option<FunctionReference> POST_PROCESS = new ItemOption<>(
|
327 |
| - Type.FUNCTION_REFERENCE,"post-process", v1_0, v2_0, v3_0); |
| 326 | + Type.FUNCTION_REFERENCE,"post-process", V1_0, V2_0, V3_0); |
328 | 327 | private static final Option<MapType> REQUESTED_PROPERTIES = new ItemOption<>(
|
329 |
| - Type.MAP,"requested-properties", v1_0, v2_0, v3_0); |
| 328 | + Type.MAP,"requested-properties", V1_0, V2_0, V3_0); |
330 | 329 | private static final Option<MapType> SERIALIZATION_PARAMS = new ItemOption<>(
|
331 |
| - Type.MAP,"serialization-params", v1_0, v2_0, v3_0); |
| 330 | + Type.MAP,"serialization-params", V1_0, V2_0, V3_0); |
332 | 331 | static final Option<NodeValue> SOURCE_NODE = new ItemOption<>(
|
333 |
| - Type.NODE,"source-node", v1_0, v2_0, v3_0); |
| 332 | + Type.NODE,"source-node", V1_0, V2_0, V3_0); |
334 | 333 | private static final Option<MapType> STATIC_PARAMS = new ItemOption<>(
|
335 |
| - Type.MAP,"static-params", v3_0); |
| 334 | + Type.MAP,"static-params", V3_0); |
336 | 335 | private static final Option<StringValue> STYLESHEET_BASE_URI = new ItemOption<>(
|
337 |
| - Type.STRING, "stylesheet-base-uri", v1_0, v2_0, v3_0); |
| 336 | + Type.STRING, "stylesheet-base-uri", V1_0, V2_0, V3_0); |
338 | 337 | static final Option<StringValue> STYLESHEET_LOCATION = new ItemOption<>(
|
339 |
| - Type.STRING,"stylesheet-location", v1_0, v2_0, v3_0); |
| 338 | + Type.STRING,"stylesheet-location", V1_0, V2_0, V3_0); |
340 | 339 | static final Option<NodeValue> STYLESHEET_NODE = new ItemOption<>(
|
341 |
| - Type.NODE,"stylesheet-node", v1_0, v2_0, v3_0); |
| 340 | + Type.NODE,"stylesheet-node", V1_0, V2_0, V3_0); |
342 | 341 | private static final Option<MapType> STYLESHEET_PARAMS = new ItemOption<>(
|
343 |
| - Type.MAP,"stylesheet-params", v1_0, v2_0, v3_0); |
| 342 | + Type.MAP,"stylesheet-params", V1_0, V2_0, V3_0); |
344 | 343 | static final Option<StringValue> STYLESHEET_TEXT = new ItemOption<>(
|
345 |
| - Type.STRING,"stylesheet-text", v1_0, v2_0, v3_0); |
| 344 | + Type.STRING,"stylesheet-text", V1_0, V2_0, V3_0); |
346 | 345 | private static final Option<MapType> TEMPLATE_PARAMS = new ItemOption<>(
|
347 |
| - Type.MAP,"template-params", v3_0); |
| 346 | + Type.MAP,"template-params", V3_0); |
348 | 347 | private static final Option<MapType> TUNNEL_PARAMS = new ItemOption<>(
|
349 |
| - Type.MAP,"tunnel-params", v3_0); |
| 348 | + Type.MAP,"tunnel-params", V3_0); |
350 | 349 | private static final Option<MapType> VENDOR_OPTIONS = new ItemOption<>(
|
351 |
| - Type.MAP,"vendor-options", v1_0, v2_0, v3_0); |
| 350 | + Type.MAP,"vendor-options", V1_0, V2_0, V3_0); |
352 | 351 | private static final Option<DecimalValue> XSLT_VERSION = new ItemOption<>(
|
353 |
| - Type.DECIMAL,"xslt-version", v1_0, v2_0, v3_0); |
| 352 | + Type.DECIMAL,"xslt-version", V1_0, V2_0, V3_0); |
354 | 353 |
|
355 |
| - static abstract class Option<T> { |
356 |
| - public static final float v1_0 = 1.0f; |
357 |
| - public static final float v2_0 = 2.0f; |
358 |
| - public static final float v3_0 = 3.0f; |
| 354 | + abstract static class Option<T> { |
| 355 | + public static final float V1_0 = 1.0f; |
| 356 | + public static final float V2_0 = 2.0f; |
| 357 | + public static final float V3_0 = 3.0f; |
359 | 358 |
|
360 | 359 | protected final StringValue name;
|
361 | 360 | protected final Optional<T> defaultValue;
|
@@ -407,18 +406,16 @@ public SequenceOption(final int sequenceSubtype, final int itemSubtype, final St
|
407 | 406 | public Optional<T> get(final MapType options) throws XPathException {
|
408 | 407 | if (options.contains(name)) {
|
409 | 408 | final Sequence sequence = options.get(name);
|
410 |
| - if (sequence != null) { |
411 |
| - if (Type.subTypeOf(sequence.getItemType(), sequenceSubtype)) { |
412 |
| - return Optional.of((T) sequence); |
413 |
| - } |
414 |
| - final Item item0 = options.get(name).itemAt(0); |
415 |
| - if (item0 != null) { |
416 |
| - if (Type.subTypeOf(item0.getType(), itemSubtype)) { |
417 |
| - return Optional.of((T) item0); |
418 |
| - } else { |
419 |
| - throw new XPathException( |
420 |
| - ErrorCodes.XPTY0004, "Type error: expected " + Type.getTypeName(itemSubtype) + ", got " + Type.getTypeName(sequence.getItemType())); |
421 |
| - } |
| 409 | + if (Type.subTypeOf(sequence.getItemType(), sequenceSubtype)) { |
| 410 | + return Optional.of((T) sequence); |
| 411 | + } |
| 412 | + final Item item0 = options.get(name).itemAt(0); |
| 413 | + if (item0 != null) { |
| 414 | + if (Type.subTypeOf(item0.getType(), itemSubtype)) { |
| 415 | + return Optional.of((T) item0); |
| 416 | + } else { |
| 417 | + throw new XPathException( |
| 418 | + ErrorCodes.XPTY0004, "Type error: expected " + Type.getTypeName(itemSubtype) + ", got " + Type.getTypeName(sequence.getItemType())); |
422 | 419 | }
|
423 | 420 | }
|
424 | 421 | }
|
|
0 commit comments