XPath request - DTD aware XML - attribute default value
Oxygen general issues.
-
- Posts: 20
- Joined: Fri Apr 22, 2011 4:17 pm
XPath request - DTD aware XML - attribute default value
Post by matthieu.ricaud »
Hi all,
I try this xpath request :
on an XML document with a DOCTYPE declaration.
In the DTD the p/@align attribut is defined with a default value :
For this reason, the xpath request matches any p element even if no align attribute is defined on it.
I guess this is a normal behaviour, but I'd like to know if there is a way to get an Xpath request that matches only p elements with no @align attribut in the "xml string" ?
Thanks for your help,
Best Regards,
Matthieu.
PS : I used XPath2
I try this xpath request :
Code: Select all
//p[not(@align)]
In the DTD the p/@align attribut is defined with a default value :
Code: Select all
<!ENTITY % attAlign 'align (left|center|right|justify) "justify"'>
I guess this is a normal behaviour, but I'd like to know if there is a way to get an Xpath request that matches only p elements with no @align attribut in the "xml string" ?
Thanks for your help,
Best Regards,
Matthieu.
PS : I used XPath2
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XPath request - DTD aware XML - attribute default value
Hello,
XPath works on the XML model of the document which includes the DTD. This means XPath can't tell the difference between the default value of an attribute specified in the DTD and the explicit value of an attribute specified in the XML.
If you want to search the XML text, I recommend using the Find > Find/Replace dialog.
Though I will admit it's somewhat difficult to search in text for strings that do NOT contain a certain keyword.
Regards,
Adrian
XPath works on the XML model of the document which includes the DTD. This means XPath can't tell the difference between the default value of an attribute specified in the DTD and the explicit value of an attribute specified in the XML.
If you want to search the XML text, I recommend using the Find > Find/Replace dialog.
Though I will admit it's somewhat difficult to search in text for strings that do NOT contain a certain keyword.
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: 20
- Joined: Fri Apr 22, 2011 4:17 pm
Re: XPath request - DTD aware XML - attribute default value
Post by matthieu.ricaud »
Hi Adrian, Hi George,
Thanks a lot for your both answers.
I actually didn't want to desactivate the DTD neither using the search tool (although with a bit of regex, it could do the trick, for sure).
But I guess I have no choice as I don't see any options to ignore DTD (or ignore xml catalog) while submiting an xpath request.
I don't know if these options might be usefull in the wish list as it's actually not a good XML practice !?
A last solution would be to search this xpath : //p[@align='justify']
as "justify" is the default value defined in the DTD, it will match every p that do not have an @align attribute... + those whose value is "justify", which is XML equivalent. But no way to distinguish them both.
Thanks again for your time, everything is clear.
Cheers,
Matthieu.
Thanks a lot for your both answers.
I actually didn't want to desactivate the DTD neither using the search tool (although with a bit of regex, it could do the trick, for sure).
But I guess I have no choice as I don't see any options to ignore DTD (or ignore xml catalog) while submiting an xpath request.
I don't know if these options might be usefull in the wish list as it's actually not a good XML practice !?
A last solution would be to search this xpath : //p[@align='justify']
as "justify" is the default value defined in the DTD, it will match every p that do not have an @align attribute... + those whose value is "justify", which is XML equivalent. But no way to distinguish them both.
Thanks again for your time, everything is clear.
Cheers,
Matthieu.
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: XPath request - DTD aware XML - attribute default value
Hi Matthieu,
Of course you can use a catalog to direct the actual DTD to an empty DTD and thus remove the default attributes. But that requires setting a catalog to oXygen, run the XPath then remove the catalog... which is a lot more than just commenting the DOCTYPE declaration, run the XPath and uncomment the DOCTYPE declaration.
Best Regards,
George
Of course you can use a catalog to direct the actual DTD to an empty DTD and thus remove the default attributes. But that requires setting a catalog to oXygen, run the XPath then remove the catalog... which is a lot more than just commenting the DOCTYPE declaration, run the XPath and uncomment the DOCTYPE declaration.
Best Regards,
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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