Preserve Whitespace For Elements with Specific Text
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 171
- Joined: Thu Aug 30, 2018 10:06 pm
Preserve Whitespace For Elements with Specific Text
Post by dreifsnider »
Hi Oxygen Folks,
I'm attempting to use the Preserve space list in the Preferences under Editor / Format / XML / Elements Spacing to preserve spaces for elements that contain specific text; however, this does not work as expected.
Specifically, I'd like to be able to preserve the space for any ph element that contains text wrapped in quotation marks. The Xpath that I'm attempting to use is:
This Xpath works as expected when using the Xpath/Xquery Builder view, meaning that the ph elements are selected. However, any ph elements that contain matching text are still broken into multiple lines when using the Format and Indent operation.
For context why I'd like to preserve the space in ph elements that have text wrapped in quotation marks, we have an additional transformation post-processing tool that identifies text wrapped in quotation marks and compares it to a list of web page titles. If a matching title is found the tool builds a link between the text and the page. However, this tool does not work for text that spans across multiple lines and thus we want to preserve the spaces (and ultimately lines) for this text.
Thank you!
I'm attempting to use the Preserve space list in the Preferences under Editor / Format / XML / Elements Spacing to preserve spaces for elements that contain specific text; however, this does not work as expected.
Specifically, I'd like to be able to preserve the space for any ph element that contains text wrapped in quotation marks. The Xpath that I'm attempting to use is:
Code: Select all
ph[text()[matches(., '"[a-z|A-Z|\s]*"')]]
For context why I'd like to preserve the space in ph elements that have text wrapped in quotation marks, we have an additional transformation post-processing tool that identifies text wrapped in quotation marks and compares it to a list of web page titles. If a matching title is found the tool builds a link between the text and the page. However, this tool does not work for text that spans across multiple lines and thus we want to preserve the spaces (and ultimately lines) for this text.
Thank you!
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Preserve Whitespace For Elements with Specific Text
Hi,
In the Oxygen Preferences->"Editor / Format / XML / Elements Spacing" there is this message on top of the list of defined elements:
Ideally you would mark such ph elements with a certain "outputclass" attribute value and then match them based on that outputclass value.
https://www.oxygenxml.com/doc/ug-editor ... ng-section
Regards,
Radu
In the Oxygen Preferences->"Editor / Format / XML / Elements Spacing" there is this message on top of the list of defined elements:
Screenshot 2024-02-05 at 07.43.31.png
So the XPath expressions need to be simple (name and attribute tests). We do not support pattern matching on the text content of elements.Ideally you would mark such ph elements with a certain "outputclass" attribute value and then match them based on that outputclass value.
https://www.oxygenxml.com/doc/ug-editor ... ng-section
Regards,
Radu
You do not have the required permissions to view the files attached to this post.
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 171
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Preserve Whitespace For Elements with Specific Text
Post by dreifsnider »
Hi Radu,
Thank you for the reply! I understand about the name and attribute test, although I found the term "simple" to be ambiguous, hence my question.
Would it be possible to support more advanced XPath expressions in a future version? It would be nice if we had even greater granular control over determining what is affected by the Format and Indent operation.
Thank you!
Daniel
Thank you for the reply! I understand about the name and attribute test, although I found the term "simple" to be ambiguous, hence my question.
Would it be possible to support more advanced XPath expressions in a future version? It would be nice if we had even greater granular control over determining what is affected by the Format and Indent operation.
Thank you!
Daniel
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Preserve Whitespace For Elements with Specific Text
Hi Daniel,
I added an internal issue based on your request, pasting the issue ID for future reference:
EXM-54178 Improve xpath evaluation for preserve space elements to check in elements text
I'm skeptical the issue will get implement, we are not running the XPath expressions with the XSLT processor, we have our small engine which runs very simple expressions.
For example for your xpath:
our small engine would need to start supporting the text() function and a matches() function with regular expressions.
Regards,
Radu
I added an internal issue based on your request, pasting the issue ID for future reference:
EXM-54178 Improve xpath evaluation for preserve space elements to check in elements text
I'm skeptical the issue will get implement, we are not running the XPath expressions with the XSLT processor, we have our small engine which runs very simple expressions.
For example for your xpath:
Code: Select all
ph[text()[matches(., '"[a-z|A-Z|\s]*"')]]
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: Preserve Whitespace For Elements with Specific Text
Post by chrispitude »
Hi dreifsnider,
What language is your post-processing tool written in? Maybe it can be upgraded to normalize spaces in each string before it compares them?
"Normalizing spaces" typically means replace multiple spaces/newlines with a single space, and removing leading/trailing whitespace completely.
What language is your post-processing tool written in? Maybe it can be upgraded to normalize spaces in each string before it compares them?
"Normalizing spaces" typically means replace multiple spaces/newlines with a single space, and removing leading/trailing whitespace completely.
-
- Posts: 171
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Preserve Whitespace For Elements with Specific Text
Post by dreifsnider »
Hi Radu,
Hi chrispitude,
Thanks!
I understand your standpoint. My team would still find it a valuable addition, as we've discovered that the Preserve text as is option does not consistently work for non-roman characters, specifically Japanese. Therefore, we've been hoping to use more advanced Xpath and Regex expressions to better identify multi-alphabet characters.I'm skeptical the issue will get implement, we are not running the XPath expressions with the XSLT processor, we have our small engine which runs very simple expressions.
Hi chrispitude,
I'm not the original developer of the post processing tool, so I'm unsure what language it was written in or if it is even still is actively maintained. I'll reach out to some of my contacts with this suggestion though, as it would indeed be a better experience than requiring the XML text be formatted a specific way.What language is your post-processing tool written in? Maybe it can be upgraded to normalize spaces in each string before it compares them?
Thanks!
-
- Posts: 9431
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Preserve Whitespace For Elements with Specific Text
Hi Daniel,
About this remark:
Regards,
Radu
About this remark:
Could you elaborate maybe with some steps and an example?My team would still find it a valuable addition, as we've discovered that the Preserve text as is option does not consistently work for non-roman characters, specifically Japanese.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 171
- Joined: Thu Aug 30, 2018 10:06 pm
Re: Preserve Whitespace For Elements with Specific Text
Post by dreifsnider »
Hi Radu,
I'll check with my Japanese colleagues to see if they can reproduce this.
Thanks,
Daniel
I'll check with my Japanese colleagues to see if they can reproduce this.
Thanks,
Daniel
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