Using XPath to refactor xml in oxygen
Posted: Wed Aug 09, 2017 10:18 am
have an xml doc that I am trying to reorganize and reformat. I have been trying to use oxygen's refactoring tool to wrap specific elements or group of elements. But instead of grouping the desired elements together, it just wraps each matched element individually. How do I write an XPath expression that targets and groups elements in this manner:
Using the Wrap Element tool to wrap the first 3 chunk elements together in an s element.
Going from this:
To this
Using the the XPath expression: /systems/system/chunk[position()<4] to select the first 3 chunk elements and enclose them with s tags. However when I run this in the refactoring command I get this:
Where it selects the proper chunks, but wraps each chunk individually. Please let me know if you have any suggestions on how to group all elements together in s tags. Or if I shouldn't even be using oxygen xml to accomplish this.
Using the Wrap Element tool to wrap the first 3 chunk elements together in an s element.
Going from this:
Code: Select all
<system>
<n>1057</n>
<chunk>X1</chunk>
<chunk>C6HF5</chunk>
<chunk>Pentafluorbenzol</chunk>
<chunk>C6H2F41,2,3,5-Tetrafluorbenzol</chunk>
<chunk>Äquimolare Mischung: </chunk>
<chunk/>
<r>[F5]</r>
<c>25°C</c>
<chunk>ΔHM = 1,84 cal/mol Misch. = 7,7 J/mol Misch.</chunk>
Code: Select all
<system>
<n>1057</n>
<s><chunk>X1</chunk>
<chunk>C6HF5</chunk>
<chunk>Pentafluorbenzol</chunk></s>
<chunk>C6H2F41,2,3,5-Tetrafluorbenzol</chunk>
<chunk>Äquimolare Mischung: </chunk>
<chunk/>
<r>[F5]</r>
<c>25°C</c>
<chunk>ΔHM = 1,84 cal/mol Misch. = 7,7 J/mol Misch.</chunk>
Code: Select all
<system>
<n>1057</n>
<s><chunk>X1</chunk></s>
<s><chunk>C6HF5</chunk></s>
<s><chunk>Pentafluorbenzol</chunk></s>
<chunk>C6H2F41,2,3,5-Tetrafluorbenzol</chunk>
<chunk>Äquimolare Mischung: </chunk>
<chunk/>
<r>[F5]</r>
<c>25°C</c>
<chunk>ΔHM = 1,84 cal/mol Misch. = 7,7 J/mol Misch.</chunk>