mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-07 14:25:38 +00:00
chore: add xml namespace prefix test cases
This commit is contained in:
parent
23060cb8af
commit
df92decbe0
@ -319,7 +319,10 @@ Defaults to true
|
|||||||
Given a sample.xml file of:
|
Given a sample.xml file of:
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">
|
||||||
|
<item foo="bar">baz</item>
|
||||||
|
<xsi:item>foobar</xsi:item>
|
||||||
|
</map>
|
||||||
|
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
@ -329,13 +332,19 @@ yq --xml-keep-namespace=false '.' sample.xml
|
|||||||
will output
|
will output
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<map xmlns="some-namespace" xsi="some-instance" schemaLocation="some-url"></map>
|
<map xmlns="some-namespace" xsi="some-instance" schemaLocation="some-url">
|
||||||
|
<item foo="bar">baz</item>
|
||||||
|
<item>foobar</item>
|
||||||
|
</map>
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of
|
instead of
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">
|
||||||
|
<item foo="bar">baz</item>
|
||||||
|
<item>foobar</item>
|
||||||
|
</map>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parse xml: keep raw attribute namespace
|
## Parse xml: keep raw attribute namespace
|
||||||
@ -344,7 +353,10 @@ Defaults to true
|
|||||||
Given a sample.xml file of:
|
Given a sample.xml file of:
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">
|
||||||
|
<item foo="bar">baz</item>
|
||||||
|
<xsi:item>foobar</xsi:item>
|
||||||
|
</map>
|
||||||
|
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
@ -354,13 +366,19 @@ yq --xml-raw-token=false '.' sample.xml
|
|||||||
will output
|
will output
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" some-instance:schemaLocation="some-url"></map>
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" some-instance:schemaLocation="some-url">
|
||||||
|
<item foo="bar">baz</item>
|
||||||
|
<item>foobar</item>
|
||||||
|
</map>
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of
|
instead of
|
||||||
```xml
|
```xml
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">
|
||||||
|
<item foo="bar">baz</item>
|
||||||
|
<item>foobar</item>
|
||||||
|
</map>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Encode xml: simple
|
## Encode xml: simple
|
||||||
|
|||||||
@ -188,7 +188,10 @@ above_cat
|
|||||||
`
|
`
|
||||||
|
|
||||||
const inputXMLWithNamespacedAttr = `<?xml version="1.0"?>
|
const inputXMLWithNamespacedAttr = `<?xml version="1.0"?>
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">
|
||||||
|
<item foo="bar">baz</item>
|
||||||
|
<xsi:item>foobar</xsi:item>
|
||||||
|
</map>
|
||||||
`
|
`
|
||||||
|
|
||||||
const expectedYAMLWithNamespacedAttr = `+p_xml: version="1.0"
|
const expectedYAMLWithNamespacedAttr = `+p_xml: version="1.0"
|
||||||
@ -196,6 +199,10 @@ map:
|
|||||||
+@xmlns: some-namespace
|
+@xmlns: some-namespace
|
||||||
+@xmlns:xsi: some-instance
|
+@xmlns:xsi: some-instance
|
||||||
+@xsi:schemaLocation: some-url
|
+@xsi:schemaLocation: some-url
|
||||||
|
item:
|
||||||
|
- +content: baz
|
||||||
|
+@foo: bar
|
||||||
|
- foobar
|
||||||
`
|
`
|
||||||
|
|
||||||
const expectedYAMLWithRawNamespacedAttr = `+p_xml: version="1.0"
|
const expectedYAMLWithRawNamespacedAttr = `+p_xml: version="1.0"
|
||||||
@ -203,6 +210,10 @@ map:
|
|||||||
+@xmlns: some-namespace
|
+@xmlns: some-namespace
|
||||||
+@xmlns:xsi: some-instance
|
+@xmlns:xsi: some-instance
|
||||||
+@xsi:schemaLocation: some-url
|
+@xsi:schemaLocation: some-url
|
||||||
|
item:
|
||||||
|
- +content: baz
|
||||||
|
+@foo: bar
|
||||||
|
- foobar
|
||||||
`
|
`
|
||||||
|
|
||||||
const expectedYAMLWithoutRawNamespacedAttr = `+p_xml: version="1.0"
|
const expectedYAMLWithoutRawNamespacedAttr = `+p_xml: version="1.0"
|
||||||
@ -210,6 +221,10 @@ map:
|
|||||||
+@xmlns: some-namespace
|
+@xmlns: some-namespace
|
||||||
+@xmlns:xsi: some-instance
|
+@xmlns:xsi: some-instance
|
||||||
+@some-instance:schemaLocation: some-url
|
+@some-instance:schemaLocation: some-url
|
||||||
|
item:
|
||||||
|
- +content: baz
|
||||||
|
+@foo: bar
|
||||||
|
- foobar
|
||||||
`
|
`
|
||||||
|
|
||||||
const xmlWithCustomDtd = `
|
const xmlWithCustomDtd = `
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user