Remove wrapping p tag in table entries
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 110
- Joined: Fri May 14, 2010 12:14 am
Remove wrapping p tag in table entries
Greetings,
I'm dusting off my XPath skills and have forgotten more than I thought. I've done many searches, but have yet to divine an answer. In XSLT, I need to find all cells with a particular type of table and have their entire contents wrapped in a single paragraph element with nothing before or after that tag, and strip out the wrapping p element. I can select the cells I'm after that having only one p tag using the following XPath in Oxygen's XPath debugger:
//table[contains(@outputclass,'BitFieldTable')]//entry[@colname='Description'][count(p) = 1]
However, this p element can be anywhere, and I want to insure that there are no other tags or text nodes before or after it. The DITA in question is generated by upstream processes that have used different DITA generation logic with successive versions of the generator. DeltaXML is seeing these as false positive differences, and I'm creating an XSLT in the pipeline to normalize generator differences before the diff takes place.
As a side question, when I copy the above XPath expression into the XWatch view, nothing appears in the value column. Do the expressions in XWatch only evaluate in the context of running an XSLT stylesheet in the debugger? If so, would creating an identity transform be sufficient?
John
I'm dusting off my XPath skills and have forgotten more than I thought. I've done many searches, but have yet to divine an answer. In XSLT, I need to find all cells with a particular type of table and have their entire contents wrapped in a single paragraph element with nothing before or after that tag, and strip out the wrapping p element. I can select the cells I'm after that having only one p tag using the following XPath in Oxygen's XPath debugger:
//table[contains(@outputclass,'BitFieldTable')]//entry[@colname='Description'][count(p) = 1]
However, this p element can be anywhere, and I want to insure that there are no other tags or text nodes before or after it. The DITA in question is generated by upstream processes that have used different DITA generation logic with successive versions of the generator. DeltaXML is seeing these as false positive differences, and I'm creating an XSLT in the pipeline to normalize generator differences before the diff takes place.
As a side question, when I copy the above XPath expression into the XWatch view, nothing appears in the value column. Do the expressions in XWatch only evaluate in the context of running an XSLT stylesheet in the debugger? If so, would creating an identity transform be sufficient?
John
-
- Posts: 110
- Joined: Fri May 14, 2010 12:14 am
Re: Remove wrapping p tag in table entries
Update: I'm able to locate the table cells I want with:
which will find the table cells I'm looking for, such as:
Now I just need to unwrap and omit the paragraph tag in the output. There's a lot of implicit stuff going on in XSLT and XPath, which is great, once a critical mass of understanding is achieved.
Code: Select all
//table[contains(@outputclass,'BitFieldTable')]//entry[@colname='Description'][count(p) = 1 and count(p/*) = 0 and count(node()) = 1]
Code: Select all
<entry colname="Description"><p>Captures xyz signals</p></entry>
or
<entry colname="Description"><p></p></entry>
-
- Posts: 404
- Joined: Thu Aug 21, 2003 11:36 am
- Location: Craiova
- Contact:
Re: Remove wrapping p tag in table entries
Post by radu_pisoi »
Hi,
Some of the advantages of the XML Refactoring tool over a normal XSLT transformation are:
* the DOCTYPE declaration is preserved;
* the entities are not expanded;
* the default attributes are not added;
You can find additional information about XML Refactoring tool in our documentation, http://oxygenxml.com/doc/versions/17.1/ ... ments.html
Now, regarding your request, to unwrap the paragraph tag in the output:
* open the XML Refactoring dialog from the Tools menu;
* select the Unwrap operation;
* specify the XPath that selects the elements you want to unwrap;
* specify the operation scope, files affected by the operation. If you are working with DITA, you can simply select the 'Current DITA map hierarchy'.
In this case, a solution is to use the XML Refactoring tool that was designed for modifying the structure of a collection of XML documents.kirkilj wrote:Now I just need to unwrap and omit the paragraph tag in the output. There's a lot of implicit stuff going on in XSLT and XPath, which is great, once a critical mass of understanding is achieved.
Some of the advantages of the XML Refactoring tool over a normal XSLT transformation are:
* the DOCTYPE declaration is preserved;
* the entities are not expanded;
* the default attributes are not added;
You can find additional information about XML Refactoring tool in our documentation, http://oxygenxml.com/doc/versions/17.1/ ... ments.html
Now, regarding your request, to unwrap the paragraph tag in the output:
* open the XML Refactoring dialog from the Tools menu;
* select the Unwrap operation;
* specify the XPath that selects the elements you want to unwrap;
* specify the operation scope, files affected by the operation. If you are working with DITA, you can simply select the 'Current DITA map hierarchy'.
Radu Pisoi
<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: 110
- Joined: Fri May 14, 2010 12:14 am
Re: Remove wrapping p tag in table entries
Hello Radu,
I did not provide one critical piece of context. This transformation is going to run as part of a batch process. I'm using Oxygen as an XSLT development and debugging tool, and the use of the Refactor functionality is not an option.
John
I did not provide one critical piece of context. This transformation is going to run as part of a batch process. I'm using Oxygen as an XSLT development and debugging tool, and the use of the Refactor functionality is not an option.
John
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