Refactoring: delete an attribute value
Are you missing a feature? Request its implementation here.
-
- Posts: 1
- Joined: Thu Nov 15, 2018 1:28 pm
Refactoring: delete an attribute value
We're doing some clean-up of our DITA files now and have one attribute value that we want to get rid of.
The only way I came up with so far is to use "replace in attribute value", find all instances of the attribute I want, and replace it with nothing. This, however, leaves attributes with redundant spaces where there was more than one value (I already deleted all elements that have only this one attribute, we want to get rid of those entirely). I solved this manually, but it's not very convenient.
Can there be a refactoring operation that deletes a certain value from an attribute and any leftover spaces?
Examples of spaces, assuming that a "value2" was replaced with nothing:
The only way I came up with so far is to use "replace in attribute value", find all instances of the attribute I want, and replace it with nothing. This, however, leaves attributes with redundant spaces where there was more than one value (I already deleted all elements that have only this one attribute, we want to get rid of those entirely). I solved this manually, but it's not very convenient.
Can there be a refactoring operation that deletes a certain value from an attribute and any leftover spaces?
Examples of spaces, assuming that a "value2" was replaced with nothing:
Code: Select all
</tag @att=" value1">
</tag @att="value1 ">
</tag @att="value1 value3">
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Refactoring: delete an attribute value
Hi,
I would see this refactoring as being done in two waves:
1) Remove the value from the attribute (which you have already done using our default refactoring action).
2) Normalize the values of all existing attributes (remove leading and trailing spaces and also remove consecutive spaces between value tokens).
For (2) you can implement your own XML Refactoring action based on XSLT:
https://www.oxygenxml.com/doc/versions/ ... tools.html
The XML operation descriptor file would look like this:
and the XSLT would look like this:
The XSLT needs to be changed depending on that specific XSLT attribute you want to match.
Once you have the XML descriptor file and the XSLT in a folder, you can refer to that folder from the Oxygen Preferences->"XMl Refactoring" page and after this when using the "XMl Refactoring" action from the "Tools" main menu you should have the new action available there.
Regards,
Radu
I would see this refactoring as being done in two waves:
1) Remove the value from the attribute (which you have already done using our default refactoring action).
2) Normalize the values of all existing attributes (remove leading and trailing spaces and also remove consecutive spaces between value tokens).
For (2) you can implement your own XML Refactoring action based on XSLT:
https://www.oxygenxml.com/doc/versions/ ... tools.html
The XML operation descriptor file would look like this:
Code: Select all
<refactoringOperationDescriptor
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.oxygenxml.com/ns/xmlRefactoring" id="normalizeAttrValues" name="Normalize Attr Values">
<description>Normalize attribute values.</description>
<script type="XSLT" href="normalizeAttrValues.xsl"/>
</refactoringOperationDescriptor>
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@att">
<xsl:attribute name="att" select="normalize-space(.)"/>
</xsl:template>
</xsl:stylesheet>
Once you have the XML descriptor file and the XSLT in a folder, you can refer to that folder from the Oxygen Preferences->"XMl Refactoring" page and after this when using the "XMl Refactoring" action from the "Tools" main menu you should have the new action available there.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Refactoring: delete an attribute value
Post by chrispitude »
We need a similar solution for DITA authoring in Oxygen XML Author. Specifically, we need a way to remove a specific profiling condition value from the @props attribute throughout the entire project.
- Delete just that value from @props if there are multiple values
- Remove the @props attribute completely if it becomes empty
- Delete <ph props=”…”>…</ph> span elements that become superfluous because of this
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Refactoring: delete an attribute value
Post by chrispitude »
Hi all,
I've submitted an enhancement request for a new XML refactoring operation that can delete a value out of an attribute.
I've submitted an enhancement request for a new XML refactoring operation that can delete a value out of an attribute.
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