XML refactoring: wrap element
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 19
- Joined: Thu Nov 14, 2013 1:04 pm
XML refactoring: wrap element
Post by joerg.hambuch »
Hi,
I try to wrap several elements with another one using the Wrap Element operation but I don't get the expected result.
My XML looks like this:
What I like to get is the following:
As Target Elements I entered the following XPath: y-a, y-b, y-c
As Local Name I entered: y
What I get is:
Could you please advise what XPath expression I should enter as Target Elements to get my expected result?
Follow-up question: What should the XPath expression look like, if I have the mentioned XML code in several files and in some of them there is no <y-b> , but <y-a> and <y-c> only?
Thanks a lot,
Jörg
I try to wrap several elements with another one using the Wrap Element operation but I don't get the expected result.
My XML looks like this:
Code: Select all
<x>
<y-a>some text</y-a>
<y-b>some text</y-b>
<y-c>some text</y-b>
</x>
Code: Select all
<x>
<y>
<y-a>some text</y-a>
<y-b>some text</y-b>
<y-c>some text</y-b>
</y>
</x>
As Local Name I entered: y
What I get is:
Code: Select all
<x>
<y>
<y-a>some text</y-a>
</y>
<y>
<y-b>some text</y-b>
</y>
<y>
<y-c>some text</y-c>
</y>
</x>
Follow-up question: What should the XPath expression look like, if I have the mentioned XML code in several files and in some of them there is no <y-b> , but <y-a> and <y-c> only?
Thanks a lot,
Jörg
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XML refactoring: wrap element
Hello,
You seem to be using the wrong operation, if you want to wrap all (not each) of the elements from "x" (all its content) with a single element "y".
"Wrap element" wraps each of the elements specified by the XPath with the specified wrapper element.
You need to use the "Wrap element content" operation and specify the parent of those elements in the XPath, "x".
Regards,
Adrian
You seem to be using the wrong operation, if you want to wrap all (not each) of the elements from "x" (all its content) with a single element "y".
"Wrap element" wraps each of the elements specified by the XPath with the specified wrapper element.
You need to use the "Wrap element content" operation and specify the parent of those elements in the XPath, "x".
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 19
- Joined: Thu Nov 14, 2013 1:04 pm
Re: XML refactoring: wrap element
Post by joerg.hambuch »
Hi,
thanks for your reply. Sorry, I missed a important detail in my post: The XML contains elements on the same level, and those elements should not be wrapped.
The code looks like this:
Any idea?
Thanks,
Jörg
thanks for your reply. Sorry, I missed a important detail in my post: The XML contains elements on the same level, and those elements should not be wrapped.
The code looks like this:
Code: Select all
<x>
<element_that_should_not_be_wrapped>some text</element_that_should_not_be_wrapped>
<y-a>some text</y-a>
<y-b>some text</y-b>
<y-c>some text</y-b>
<element_that_also_should_not_be_wrapped>some text</element_that_also_should_not_be_wrapped>
</x>
Thanks,
Jörg
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XML refactoring: wrap element
Hi,
I'm afraid you can't do that one with the predefined XML Refactoring actions.
You'll need a Custom Refactoring Operation or an XSLT stylesheet.
Regards,
Adrian
I'm afraid you can't do that one with the predefined XML Refactoring actions.
You'll need a Custom Refactoring Operation or an XSLT stylesheet.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service