Should Schematron Quick Fixes be Offered for Attributes?
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 106
- Joined: Wed Dec 18, 2013 3:07 am
Should Schematron Quick Fixes be Offered for Attributes?
Hello,
Using Author 17.0. Working in DITA.
Apologies if this is not the right place to ask, but I can't find any relevant information on this:
I have a schematron that checks ids to see if they contain underscores, which we do not allow.
I have set a quick fix to replace underscores with hyphens, like this:
The schematron finds the underscores but the quick fix is not offered.
I have tried the same quick fix with the context set as an element, and the quick fix is offered and works, so I'm assuming the problem is that quick fixes don't work for attributes. Is that correct? As I said, I can't find a definitive statement on this anywhere, and it seems strange that the schematron finds the error but the quick fix isn't offered.
Cheers,
Eddie.
Using Author 17.0. Working in DITA.
Apologies if this is not the right place to ask, but I can't find any relevant information on this:
I have a schematron that checks ids to see if they contain underscores, which we do not allow.
I have set a quick fix to replace underscores with hyphens, like this:
Code: Select all
<sch:rule context="@id">
<sch:report test="matches(.,'_')" sqf:fix="ReplaceUnderscore1" role="error">IDs must not contain underscores.</sch:report>
<sqf:fix id="ReplaceUnderscore1">
<sqf:description>
<sqf:title>Replace the underscores with hyphens.</sqf:title>
</sqf:description>
<sqf:stringReplace match="text()" regex="_">-</sqf:stringReplace>
</sqf:fix>
</sch:rule>
I have tried the same quick fix with the context set as an element, and the quick fix is offered and works, so I'm assuming the problem is that quick fixes don't work for attributes. Is that correct? As I said, I can't find a definitive statement on this anywhere, and it seems strange that the schematron finds the error but the quick fix isn't offered.
Cheers,
Eddie.
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Should Schematron Quick Fixes be Offered for Attributes?
Hi Eddie,
The sqf:stringReplace operation works only for text nodes, not for attribute values.
http://schematron-quickfix.github.io/sq ... tml#d0e921
The quick fix is not offered because your XPath expression from the stringReplace operation is not correct "@id/text()". You cannot use the "text()" in the context of an attribute. The "text()" selects all text node children of the context node.
If you want to change the attribute value you can use the sqf:replace operation. For example you can use this operation:
Best Regards,
Octavian
The sqf:stringReplace operation works only for text nodes, not for attribute values.
http://schematron-quickfix.github.io/sq ... tml#d0e921
The quick fix is not offered because your XPath expression from the stringReplace operation is not correct "@id/text()". You cannot use the "text()" in the context of an attribute. The "text()" selects all text node children of the context node.
If you want to change the attribute value you can use the sqf:replace operation. For example you can use this operation:
Code: Select all
<sqf:replace node-type="attribute" target="id" select="replace(., '_', '-')"/>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
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