Inserting a block of text into every record
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 4
- Joined: Tue Jul 23, 2013 9:53 pm
- Location: Moscow, Idaho
Inserting a block of text into every record
Another entry in the "this may be really obvious" series. I have a block of text for contact information metadata that I'd like to insert in each of several thousand records. I can't use a simple copy and paste, because I want to put the block after an element that appears more than once in each record (and I only want the block once in each). Is there a simple insert function that could help me do this?
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Inserting a block of text into every record
Hello,
I'm not sure if this a general XML question or an Oxygen specific one.
For general XML processing you can use an XSLT stylesheet tailored to your particular problem. I don't have enough details for your particular problem to provide a solution. The usual solution involves a customized copy stylesheet that alters specific content while copying the rest.
In Oxygen (apart from the XSL solution) this can also be accomplished with the Find/Replace tools with the help of the XPath filter and some light regular expressions. This is not exactly XML specialized, it's a text replacement tool, but it is XML-aware.
If you provide more details about the name of the element and where exactly you want to insert the text I can offer a more specific solution.
e.g. To insert a block of text after the end of the last "tag" from "record"
Text to find: </tag>
Replace with: $0block of text
XPath: //record//tag[last()]
Options: Regular expression
The result will be "</tag>block of text".
Regards,
Adrian
I'm not sure if this a general XML question or an Oxygen specific one.
For general XML processing you can use an XSLT stylesheet tailored to your particular problem. I don't have enough details for your particular problem to provide a solution. The usual solution involves a customized copy stylesheet that alters specific content while copying the rest.
In Oxygen (apart from the XSL solution) this can also be accomplished with the Find/Replace tools with the help of the XPath filter and some light regular expressions. This is not exactly XML specialized, it's a text replacement tool, but it is XML-aware.
If you provide more details about the name of the element and where exactly you want to insert the text I can offer a more specific solution.
e.g. To insert a block of text after the end of the last "tag" from "record"
Text to find: </tag>
Replace with: $0block of text
XPath: //record//tag[last()]
Options: Regular expression
The result will be "</tag>block of text".
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: 4
- Joined: Tue Jul 23, 2013 9:53 pm
- Location: Moscow, Idaho
Re: Inserting a block of text into every record
Ok, I couldn't get that to work. When I specified that XPath, it seems to have broken the search. It can't find the search text at all, let alone find and replace it. I was hoping to do this through Find/Replace rather than an XSLT. Is there not a way to just insert text at a certain line in a document?
-
- Posts: 4
- Joined: Tue Jul 23, 2013 9:53 pm
- Location: Moscow, Idaho
Re: Inserting a block of text into every record
I could also solve this if I could include line breaks in a Find/Replace in Files search. I've got a working general Find/Replace setup, but it only works on one file at a time.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Inserting a block of text into every record
Hi,
What XPath expression did you use?
How is the XML document structured?
If the XPath results don't match anything then the search won't be able to find anything.
Regards,
Adrian
What XPath expression did you use?
How is the XML document structured?
If the XPath results don't match anything then the search won't be able to find anything.
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: 404
- Joined: Thu Aug 21, 2003 11:36 am
- Location: Craiova
- Contact:
Re: Inserting a block of text into every record
Post by radu_pisoi »
I just wanted to let you know that the latest version (v17.0) of Oxygen contains the XML Refactoring tool that assists you with various refactoring tasks.akyrios wrote:Another entry in the "this may be really obvious" series. I have a block of text for contact information metadata that I'd like to insert in each of several thousand records. I can't use a simple copy and paste, because I want to put the block after an element that appears more than once in each record (and I only want the block once in each). Is there a simple insert function that could help me do this?
It helps you manage the structure of your XML documents and it includes a variety of operations, such as renaming, deleting, and inserting elements and attributes across a set of files. It is available in the Tools menu, the Project and DITA Maps Manager contextual menu.
In your case, you could use the 'Insert XML fragment' operation to insert a text fragment in a certain document position.
You can read more details about this feature in our documentation:
http://www.oxygenxml.com/doc/versions/1 ... ments.html
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
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