mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-07 14:25:38 +00:00
v4.30.2
This commit is contained in:
parent
245a3dbe34
commit
25e91abe3a
@ -1,4 +1,4 @@
|
|||||||
# Slice Array
|
# Slice/Splice Array
|
||||||
|
|
||||||
The slice array operator takes an array as input and returns a subarray. Like the `jq` equivalent, `.[10:15]` will return an array of length 5, starting from index 10 inclusive, up to index 15 exclusive. Negative numbers count backwards from the end of the array.
|
The slice array operator takes an array as input and returns a subarray. Like the `jq` equivalent, `.[10:15]` will return an array of length 5, starting from index 10 inclusive, up to index 15 exclusive. Negative numbers count backwards from the end of the array.
|
||||||
|
|
||||||
|
|||||||
70
usage/xml.md
70
usage/xml.md
@ -258,55 +258,55 @@ cat:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Parse xml: keep attribute namespace
|
## Parse xml: keep attribute namespace
|
||||||
|
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 xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
||||||
</map>
|
|
||||||
|
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
yq -p=xml -o=xml --xml-keep-namespace '.' sample.xml
|
yq -p=xml -o=xml --xml-keep-namespace=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>
|
|
||||||
```
|
|
||||||
|
|
||||||
instead of
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" some-instance:schemaLocation="some-url"></map>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parse xml: keep raw attribute namespace
|
|
||||||
Given a sample.xml file of:
|
|
||||||
```xml
|
|
||||||
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url">
|
|
||||||
</map>
|
|
||||||
|
|
||||||
```
|
|
||||||
then
|
|
||||||
```bash
|
|
||||||
yq -p=xml -o=xml --xml-keep-namespace --xml-raw-token '.' sample.xml
|
|
||||||
```
|
|
||||||
will output
|
|
||||||
```xml
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
<map xmlns="some-namespace" xmlns:xsi="some-instance" some-instance:schemaLocation="some-url"></map>
|
|
||||||
```
|
|
||||||
|
|
||||||
instead of
|
|
||||||
```xml
|
|
||||||
<?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"></map>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
instead of
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parse xml: keep raw attribute namespace
|
||||||
|
Defaults to true
|
||||||
|
|
||||||
|
Given a sample.xml file of:
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
||||||
|
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq -p=xml -o=xml --xml-raw-token=false '.' sample.xml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" some-instance:schemaLocation="some-url"></map>
|
||||||
|
```
|
||||||
|
|
||||||
|
instead of
|
||||||
|
```xml
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<map xmlns="some-namespace" xmlns:xsi="some-instance" xsi:schemaLocation="some-url"></map>
|
||||||
|
```
|
||||||
|
|
||||||
## Encode xml: simple
|
## Encode xml: simple
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user