diff --git a/pkg/yqlib/doc/usage/xml.md b/pkg/yqlib/doc/usage/xml.md index 4238e971..30349f06 100644 --- a/pkg/yqlib/doc/usage/xml.md +++ b/pkg/yqlib/doc/usage/xml.md @@ -319,7 +319,10 @@ Defaults to true Given a sample.xml file of: ```xml - + + baz + foobar + ``` then @@ -329,13 +332,19 @@ yq --xml-keep-namespace=false '.' sample.xml will output ```xml - + + baz + foobar + ``` instead of ```xml - + + baz + foobar + ``` ## Parse xml: keep raw attribute namespace @@ -344,7 +353,10 @@ Defaults to true Given a sample.xml file of: ```xml - + + baz + foobar + ``` then @@ -354,13 +366,19 @@ yq --xml-raw-token=false '.' sample.xml will output ```xml - + + baz + foobar + ``` instead of ```xml - + + baz + foobar + ``` ## Encode xml: simple diff --git a/pkg/yqlib/xml_test.go b/pkg/yqlib/xml_test.go index 08e1f0ae..f17d5581 100644 --- a/pkg/yqlib/xml_test.go +++ b/pkg/yqlib/xml_test.go @@ -188,7 +188,10 @@ above_cat ` const inputXMLWithNamespacedAttr = ` - + + baz + foobar + ` const expectedYAMLWithNamespacedAttr = `+p_xml: version="1.0" @@ -196,6 +199,10 @@ map: +@xmlns: some-namespace +@xmlns:xsi: some-instance +@xsi:schemaLocation: some-url + item: + - +content: baz + +@foo: bar + - foobar ` const expectedYAMLWithRawNamespacedAttr = `+p_xml: version="1.0" @@ -203,6 +210,10 @@ map: +@xmlns: some-namespace +@xmlns:xsi: some-instance +@xsi:schemaLocation: some-url + item: + - +content: baz + +@foo: bar + - foobar ` const expectedYAMLWithoutRawNamespacedAttr = `+p_xml: version="1.0" @@ -210,6 +221,10 @@ map: +@xmlns: some-namespace +@xmlns:xsi: some-instance +@some-instance:schemaLocation: some-url + item: + - +content: baz + +@foo: bar + - foobar ` const xmlWithCustomDtd = `