Global XML Attribute Change Possible?
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 26
- Joined: Wed Apr 10, 2019 7:43 pm
Global XML Attribute Change Possible?
Greetings,
Is it possible for OxygenXML to perform the following find and replace operation so it can save me a lot of time. I have 1,450 XML files. I need OxygenXML to globally look for the "colwidth" attribute through all 1,450 XML files. Two colwidth attribute examples I need to globally edit are shown below:
Example #1:
Example #2:
For all colwidth attributes missing an asterik symbol as shown in Example #2 I need OxygenXML to add the as shown in Example #1. If the colwidth attribute already has the included I need OxygenXML to skip the attribute change.
Is such an attribute find & replace operation possible to execute in OxygenXML? Any help will be greatly appreciated. Thanks in advance.
Is it possible for OxygenXML to perform the following find and replace operation so it can save me a lot of time. I have 1,450 XML files. I need OxygenXML to globally look for the "colwidth" attribute through all 1,450 XML files. Two colwidth attribute examples I need to globally edit are shown below:
Example #1:
Code: Select all
colwidth="0.83*" (not missing * character)
Code: Select all
colwidth="155.7" (missing * character)
Code: Select all
*
Code: Select all
*
Code: Select all
*
Is such an attribute find & replace operation possible to execute in OxygenXML? Any help will be greatly appreciated. Thanks in advance.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Global XML Attribute Change Possible?
Hi,
Go to the main menu Tools->XML Refactoring, choose "Replace in Attribute Value".
In the dialog set the "Element" field to *[@colwidth], the "Attribute" field to colwidth, the "Find" field to (.*)[^*]$ and the "Replace" field to $1*
You can select a working set (apply on the entire project files for example) and you also have a "Preview" to check if things are working as expected.
Regards,
Radu
Go to the main menu Tools->XML Refactoring, choose "Replace in Attribute Value".
In the dialog set the "Element" field to *[@colwidth], the "Attribute" field to colwidth, the "Find" field to (.*)[^*]$ and the "Replace" field to $1*
You can select a working set (apply on the entire project files for example) and you also have a "Preview" to check if things are working as expected.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Wed Apr 10, 2019 7:43 pm
Re: Global XML Attribute Change Possible?
Hi Radu,
Thank you very much for your post. I am amazed with this OxygenXML capability I did not know was included in the software. I followed your instructions and did a PREVIEW. Below are a couple examples of the results I am getting:
Before Change:
After Change Preview:
As you can see from the before and after examples above, OxygenXML is removing the "5" and replacing it with the asterik symbol
How can we change the find and replace values below:
Find = (.*)[^*]$
Replace = $1*
so that the number "5" remains and I get the result shown below?
Thank you for your help with this matter.
Thank you very much for your post. I am amazed with this OxygenXML capability I did not know was included in the software. I followed your instructions and did a PREVIEW. Below are a couple examples of the results I am getting:
Before Change:
Code: Select all
colwidth="98.45"
Code: Select all
colwidth="108.45"
Code: Select all
colwidth="98.4*"
Code: Select all
colwidth="108.4*"
Code: Select all
*
Find = (.*)[^*]$
Replace = $1*
so that the number "5" remains and I get the result shown below?
Code: Select all
colwidth="98.45*"
Code: Select all
colwidth="108.45*"
-
- Posts: 26
- Joined: Wed Apr 10, 2019 7:43 pm
Re: Global XML Attribute Change Possible?
Greeting Radu,
I have a followup question regarding the coding you previously posted shown below:
What name does this coding have? Is it a Regular Expression or Perl Expression or something else entirely? I ask because I have another attribute change to make using the Find & Replace fields located in "Tools->XML Refactoring, choose "Replace in Attribute Value". Below is the problem summarized.
The "item" attribute below is not validating because it needs a leading zero added in front of all two digit numbers.
In short, please help me with a find & replace code that will skip over "item" attribute values already setup with three digits. But will automatically add a leading zero to all "item" attribute values only setup with two digits.
Over the weekend I Googled this matter to see if I could find a solution. The links below shows two online testers I referred to in an effort to develop my own Find & Replace code but was not successful:
https://www.infobyip.com/regularexpress ... ulator.php
https://ingram-braun.net/public/program ... le-regexp/
In your opinion what is the best online tester to use that is compatible with XML Refactoring find & replace fields? Also I was not able to find any OxygenXML Editor documentation that provides an overview of how to write your own Find & Replace code to change Attributes.
Lastly, it would be great if a future version of OxygenXML editor included its own find & replace code tester designed to remove some of the complexity involved with this task.
Thanks for your help with this matter.
I have a followup question regarding the coding you previously posted shown below:
Code: Select all
(.*)([^*])$
$1$2*
OR
(.*)[^*]$
$1*
The "item" attribute below is not validating because it needs a leading zero added in front of all two digit numbers.
Code: Select all
item = "12" (This is the wrong format and does not validate)
Code: Select all
item = "012" (This is the correct format and validates)
Over the weekend I Googled this matter to see if I could find a solution. The links below shows two online testers I referred to in an effort to develop my own Find & Replace code but was not successful:
https://www.infobyip.com/regularexpress ... ulator.php
https://ingram-braun.net/public/program ... le-regexp/
In your opinion what is the best online tester to use that is compatible with XML Refactoring find & replace fields? Also I was not able to find any OxygenXML Editor documentation that provides an overview of how to write your own Find & Replace code to change Attributes.
Lastly, it would be great if a future version of OxygenXML editor included its own find & replace code tester designed to remove some of the complexity involved with this task.
Thanks for your help with this matter.
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Global XML Attribute Change Possible?
Hi,
These constructs are regular expressions implemented in Java based closely on PERL based expressions.
They should work and can also be tested in the Oxygen Find/Replace dialog:
https://www.oxygenxml.com/doc/versions/ ... sions.html
In your case you should probably search for ^(\d\d)$ and replace with 0$1.
Regards,
Radu
These constructs are regular expressions implemented in Java based closely on PERL based expressions.
They should work and can also be tested in the Oxygen Find/Replace dialog:
https://www.oxygenxml.com/doc/versions/ ... sions.html
In your case you should probably search for ^(\d\d)$ and replace with 0$1.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
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