Include default values in Schema for XPath query
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 9
- Joined: Wed Apr 11, 2018 4:43 pm
Include default values in Schema for XPath query
Post by daddyjones »
If an attribute is specified in my Schema as having a default value, is there a way to get the XPath query to include that value in the results? At present, my program code (which includes validation) returns 6 results from a given query, but Oxygen only returns 4 because the missing two don't have the attribute, but the Schema specifies a default value.
It would be really helpful if I could properly test my XPath before using it in code and be confident I'll get the same result...
It would be really helpful if I could properly test my XPath before using it in code and be confident I'll get the same result...
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Include default values in Schema for XPath query
Hello,
Regards,
Adrian
The XPath engine needs to be Schema Aware (SA) in order for this to work, so you must select either XPath 2.0 SA or XPath 3.0 SA from the XPath engine combo box in the toolbar (default is XPath 2.0).If an attribute is specified in my Schema as having a default value, is there a way to get the XPath query to include that value in the results?
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: 9
- Joined: Wed Apr 11, 2018 4:43 pm
Re: Include default values in Schema for XPath query
Post by daddyjones »
That doesn't seem to make any difference. I am referring to the schema in the XML with:
I've tried with both 2.0 SA and 3.0 SA
Code: Select all
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.redfruit.co.uk/libgdx/wobbegong mobs.xsd"
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Include default values in Schema for XPath query
Hi,
1. Is the schema (mobs.xsd) available locally, in the same folder as the XML, or is there an XML catalog resolving the URI to point to its location?
2. What version of Oxygen are you using?
3. What XPath expression/query are you using?
Check if your XPath expression accounts for the namespaces.
I've tested in Oxygen v20 with the XPath //@* on one of the Oxygen samples (Oxygen/samples/personal-schema.xml). With XPath 2.0 I get all the attributes from the XML (but no defaults), with XPath 2.0 SA I also get the default attributes (person/@contr=false) from the personal.xsd schema.
If possible, please try the same on this sample.
Regards,
Adrian
1. Is the schema (mobs.xsd) available locally, in the same folder as the XML, or is there an XML catalog resolving the URI to point to its location?
2. What version of Oxygen are you using?
3. What XPath expression/query are you using?
Check if your XPath expression accounts for the namespaces.
I've tested in Oxygen v20 with the XPath //@* on one of the Oxygen samples (Oxygen/samples/personal-schema.xml). With XPath 2.0 I get all the attributes from the XML (but no defaults), with XPath 2.0 SA I also get the default attributes (person/@contr=false) from the personal.xsd schema.
If possible, please try the same on this sample.
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: 9
- Joined: Wed Apr 11, 2018 4:43 pm
Re: Include default values in Schema for XPath query
Post by daddyjones »
Interestingly, if I use the person sample I get the same results as you. I'm using version 20.0 build 2018032903 and the xsd is in the same directory as the xml.
The XPath I'm using is:
and there are two elements without a minDepth attribute - which the schema defines as having a default of 0:
The XPath I'm using is:
Code: Select all
//rf:mob[@minDepth <=2]
Code: Select all
<xs:attribute name="minDepth" default="0" type="xs:int"/>
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Include default values in Schema for XPath query
Hi,
I tested with an attribute of type xs:int, but XPath still works fine for me.
Perhaps the problem is within a specific context determined by the schema?
If you'd like me to have a look, please send the schema and XML to support@oxygenxml.com.
Please make sure the schema and XML do not contain confidential information. For the XML, you can use Help > Support Tools > Randomize XML text content to make the content random.
Regards,
Adrian
I tested with an attribute of type xs:int, but XPath still works fine for me.
Perhaps the problem is within a specific context determined by the schema?
If you'd like me to have a look, please send the schema and XML to support@oxygenxml.com.
Please make sure the schema and XML do not contain confidential information. For the XML, you can use Help > Support Tools > Randomize XML text content to make the content random.
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: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Include default values in Schema for XPath query
Hi,
In case someone else encounters this, we have investigated and the XPath SA evaluation does not take into consideration default attribute values from the schema, if the XML Schema is of version 1.1 (vc:minVersion="1.1").
This has been logged on our issue tracking tool to be resolved in a future release.
Regards,
Adrian
In case someone else encounters this, we have investigated and the XPath SA evaluation does not take into consideration default attribute values from the schema, if the XML Schema is of version 1.1 (vc:minVersion="1.1").
This has been logged on our issue tracking tool to be resolved in a future release.
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
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