Live AuthorNode offset values.
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 83
- Joined: Wed May 20, 2009 1:18 pm
Live AuthorNode offset values.
Hi,
I have a search component I am building. It searches through the document for text strings that match a cerai regular expression, and then stores the AuthorNode in which the match occurs and the offset from the start of the node to the start of the matching text. This way I can find the node and the text inside the node.
A second function allows user to replace wcah of these search results with new XML. e.g. replace text that looks like a URL with a <xref> element. This function simply loops through the search results and creates an approipriate XML fragement, and then replaces the old text with the new XML. Unfortunately after the first such insert the offsets to all the susequent cached AuthorNodes is incorrect. This, I assume, is due the AuthorNodes not being 'backed' by the document model, so chnages to the document model are not reflceted in all live AuthorNode instances.
Is this something that should be happending, if so what might I being doing wrong that is preventing this updating, and if it's working as intended, is there a way to get an updated instance of an AuthorNode given an out of date instance?
Many Thanks,
Simon.
I have a search component I am building. It searches through the document for text strings that match a cerai regular expression, and then stores the AuthorNode in which the match occurs and the offset from the start of the node to the start of the matching text. This way I can find the node and the text inside the node.
A second function allows user to replace wcah of these search results with new XML. e.g. replace text that looks like a URL with a <xref> element. This function simply loops through the search results and creates an approipriate XML fragement, and then replaces the old text with the new XML. Unfortunately after the first such insert the offsets to all the susequent cached AuthorNodes is incorrect. This, I assume, is due the AuthorNodes not being 'backed' by the document model, so chnages to the document model are not reflceted in all live AuthorNode instances.
Is this something that should be happending, if so what might I being doing wrong that is preventing this updating, and if it's working as intended, is there a way to get an updated instance of an AuthorNode given an out of date instance?
Many Thanks,
Simon.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Live AuthorNode offset values.
Post by sorin_ristache »
Hello,
If the document content is modified the offsets that follow the location of the modification are not valid anymore.
You can keep a variable with the difference between the length of the replaced text and the length of the replacing text and add this difference to the offset of the second replaced text (the offset inside the second AuthorNode that is modified). After the second replace action the variable must be updated with the new difference that is created by this second replace action and add it to the offset of the third node when applying the third replace, etc.
Regards,
Sorin
If the document content is modified the offsets that follow the location of the modification are not valid anymore.
You can keep a variable with the difference between the length of the replaced text and the length of the replacing text and add this difference to the offset of the second replaced text (the offset inside the second AuthorNode that is modified). After the second replace action the variable must be updated with the new difference that is created by this second replace action and add it to the offset of the third node when applying the third replace, etc.
Regards,
Sorin
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