|
1 | 1 | <?xml version="1.0"?> |
2 | 2 | <test> |
3 | | - <hello xmlns="hello_ns"> |
4 | | - <!-- from an element name standpoint, you could expect this element to be reachable by the path "/test/hello". |
5 | | - However, XPath 1.0 does not have the concept of a default namespace. If the XML document being queried defines a default namespace, the XPath expression should map the namespace to a prefix for easier access. |
6 | | - This is what this plugin does for you. Because this is the first prefix-less namespace declared in document order, it will become "default", assuming "default" is set as the default namespace prefix to use. |
7 | | - But, because there is at least one other prefix-less namespace in the document - which resolves to a different uri - it will become "default1" instead. --> |
8 | | - |
9 | | - <!-- The scope of a default namespace declaration extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag, excluding the scope of any inner default namespace declarations. --> |
10 | | - <world xmlns="world_ns"><!-- second prefix-less namespace in doc order, becomes "default2" --> |
11 | | - <example /><!-- path here is "/test/default1:hello/default2:world/default2:example" --> |
12 | | - </world> |
13 | | - </hello> |
14 | | - <more xmlns="more_ns" xmlns:an="another_ns"><!-- third prefix-less namespace in doc order, becomes "default3". First "an" prefix declared in doc-order. Because there is more than one unique namespace uri declared with this prefix, it will become "an1" for query purposes. --> |
15 | | - <an:another></an:another><!-- path here is "/test/default3:more[1]/an1:another" --> |
16 | | - </more> |
17 | | - <more xmlns="more_ns" xmlns:an="yet_another_ns" xmlns:unique="single"><!-- this prefixless namespace has the same uri as one already used, "default3", so this is also "default3". Because the an prefix is being declared again to a different uri than the previous one, it becomes "an2". As the "unique" prefix is unique, it remains as "unique", with no numeric suffix. --> |
18 | | - <an:yet_another></an:yet_another><!-- path here is "/test/default3:more[2]/an2:yet_another" --> |
19 | | - <unique:example></unique:example><!-- path here is "/test/default3:more[2]/unique:example" --> |
20 | | - </more> |
21 | | - <foo xmlns="world_ns" /><!-- same uri as default2 used, path is therefore "/test/default2:foo" --> |
22 | | - <numeric xmlns:an="yans"><!-- this one becomes "an4", because "an" has been used twice already and "an3" is explicitly defined later in the document --> |
23 | | - <an:test /><!-- /test/numeric/an4:test --> |
24 | | - </numeric> |
25 | | - <numeric xmlns:an3="numbered_ns"><!-- specific namespace prefix with a numeric suffix declared --> |
26 | | - <an3:okay></an3:okay> |
27 | | - </numeric> |
28 | | - <text attr1="hello" attr2='world'>sample text<more some_value |
29 | | - = |
30 | | - "foobar" another_value = "super" xmlns:abc="abc" abc:another_value="value" /> lorem ipsum etc.</text>abc<![CDATA[def]]>ghi<hij><![CDATA[klm]]></hij><![CDATA[nop]]> |
| 3 | + <hello xmlns="hello_ns"> |
| 4 | + <!-- from an element name standpoint, you could expect this element to be reachable by the path "/test/hello". |
| 5 | + However, XPath 1.0 does not have the concept of a default namespace. If the XML document being queried defines a default namespace, the XPath expression should map the namespace to a prefix for easier access. |
| 6 | + This is what this plugin does for you. Because this is the first prefix-less namespace declared in document order, it will become "default", assuming "default" is set as the default namespace prefix to use. |
| 7 | + But, because there is at least one other prefix-less namespace in the document - which resolves to a different uri - it will become "default1" instead. --> |
| 8 | + |
| 9 | + <!-- The scope of a default namespace declaration extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag, excluding the scope of any inner default namespace declarations. --> |
| 10 | + <world xmlns="world_ns"><!-- second prefix-less namespace in doc order, becomes "default2" --> |
| 11 | + <example /><!-- path here is "/test/default1:hello/default2:world/default2:example" --> |
| 12 | + </world> |
| 13 | + </hello> |
| 14 | + <more xmlns="more_ns" xmlns:an="another_ns"><!-- third prefix-less namespace in doc order, becomes "default3". First "an" prefix declared in doc-order. Because there is more than one unique namespace uri declared with this prefix, it will become "an1" for query purposes. --> |
| 15 | + <an:another></an:another><!-- path here is "/test/default3:more[1]/an1:another" --> |
| 16 | + </more> |
| 17 | + <more xmlns="more_ns" xmlns:an="yet_another_ns" xmlns:unique="single"><!-- this prefixless namespace has the same uri as one already used, "default3", so this is also "default3". Because the an prefix is being declared again to a different uri than the previous one, it becomes "an2". As the "unique" prefix is unique, it remains as "unique", with no numeric suffix. --> |
| 18 | + <an:yet_another></an:yet_another><!-- path here is "/test/default3:more[2]/an2:yet_another" --> |
| 19 | + <unique:example></unique:example><!-- path here is "/test/default3:more[2]/unique:example" --> |
| 20 | + </more> |
| 21 | + <foo xmlns="world_ns" /><!-- same uri as default2 used, path is therefore "/test/default2:foo" --> |
| 22 | + <numeric xmlns:an="yans"><!-- this one becomes "an4", because "an" has been used twice already and "an3" is explicitly defined later in the document --> |
| 23 | + <an:test /><!-- /test/numeric/an4:test --> |
| 24 | + </numeric> |
| 25 | + <numeric xmlns:an3="numbered_ns"><!-- specific namespace prefix with a numeric suffix declared --> |
| 26 | + <an3:okay></an3:okay> |
| 27 | + </numeric> |
| 28 | + <text attr1="hello" attr2='world'>sample text<more some_value |
| 29 | + = |
| 30 | + "foobar" another_value = "super" xmlns:abc="abc" abc:another_value="value" /> lorem ipsum etc.</text>abc<![CDATA[def]]>ghi<hij><![CDATA[klm]]></hij><![CDATA[nop]]> |
31 | 31 | </test> |
0 commit comments