Globally Adding a Random ID Attribute?
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 26
- Joined: Wed Apr 10, 2019 7:43 pm
Globally Adding a Random ID Attribute?
I am using OxygenXML Editor. And I have a procedural data module that is 140 pages long when the XML file is converted to a PDF. The BREX I am using requires each ProceduralStep Tag include an Attribute ID comprised of a 6 digit random number. If this Attribute ID is left out the XML file does not validate without getting a bunch of errors. In short, the tag needs to look like what is shown in the example below:
Does OxygenXML Editor have a tool that targets all "proceduralstep" tags and automatically adds a random 6 digit number as an ID attribute? I have taken a look at the Refactoring toolset but I cannot find any way to generate the 6 digit random number. Any help will be greatly appreciated.
Code: Select all
<procedrualStep id=583729/>
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Globally Adding a Random ID Attribute?
Post by chrispitude »
Hi binar,
Oxygen does provide some ID attribute tools, but I'm not sure about your requirements because XML @id attributes cannot begin with a number.
Oxygen does provide some ID attribute tools, but I'm not sure about your requirements because XML @id attributes cannot begin with a number.
-
- Posts: 26
- Joined: Wed Apr 10, 2019 7:43 pm
Re: Globally Adding a Random ID Attribute?
My mistake. You are correct. I forgot about the XML rule that requires an ID attribute start with a letter. So allow me to ask my question a different way. Does OxygenXML Editor have a tool that targets all "proceduralstep" tags and automatically adds an XML approved ID attribute using Letters and Numbers? In short, can OxygenXML automatically add the Attribute ID's shown below so it includes: id=" Para0001", id=" Para0002", id=" Para0003", id=" Para0004", and id=" Para0005" with no repeats?
Code: Select all
<proceduralStep Id="Para0001">
<para>Para Level 1</para>
<proceduralStep Id="Para0002">
<para>Para Level 2</para>
<proceduralStep Id="Para0003">
<para>Para Level 3</para>
<proceduralStep Id="Para0004">
<para>Para Level 4</para>
<proceduralStep Id="Para0005">
<para>Para Level 5</para>
</proceduralStep>
</proceduralStep>
</proceduralStep>
</proceduralStep>
</proceduralStep>
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: Globally Adding a Random ID Attribute?
Post by chrispitude »
Hi binar,
Try running the Generate IDs refactoring operation (Tools > XML Refactoring). For the Element pattern, enter the element name:
In the Scope and Filters dialog, set the scope to what you want. For example, to run on all .xml files in a particular directory, you would first select that directory in the Project view, then you would set the scope to Selected project resources and the Include files filter to *.xml.
The main refactoring operation dialog lists many operations, but it also has a handy search bar that I recommend you use. You can just type in "ID" or "delete" or some other word related to what you want to do, and it should be easy to find the operation you want.
Note that the generated @id attribute will be lowercase, which is the XML convention. If you need it to be uppercase as in your example, you can use the Rename Attribute refactoring operation afterward.
- Chris
Try running the Generate IDs refactoring operation (Tools > XML Refactoring). For the Element pattern, enter the element name:
Code: Select all
proceduralStep
The main refactoring operation dialog lists many operations, but it also has a handy search bar that I recommend you use. You can just type in "ID" or "delete" or some other word related to what you want to do, and it should be easy to find the operation you want.
Note that the generated @id attribute will be lowercase, which is the XML convention. If you need it to be uppercase as in your example, you can use the Rename Attribute refactoring operation afterward.
- Chris
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