Extract all the possible xpaths from a schema

This should cover W3C XML Schema, Relax NG and DTD related problems.
andy
Posts: 3

Extract all the possible xpaths from a schema

Mon Apr 13, 2015 12:51 am

Hi,

is there a way to extract all the possible XPaths from a schema (.xsd)?

Something like
root
root/provider
root/provider/company
root/provider/company@name
root/provider/company@address
root/recipient
root/recipient/person
root/recipient/person@name
...

These are not the XPaths which are in the schema itself. Rather all the XPaths which can occur in valid xml file, that corresponds to the schema.


Thanks in advance
sorin_ristache
Posts: 4144

Re: Extract all the possible xpaths from a schema

Wed Apr 15, 2015 9:45 am

Hi,

There is no automatic way or special action for that in the Oxygen application. I suppose you can get a list of XPath expressions of all the possible XML elements and attributes in a two step process like the following:

Regards,
Sorin

<oXygen/> XML Editor Support
andy
Posts: 3

Re: Extract all the possible xpaths from a schema

Wed Apr 15, 2015 10:33 pm

ok,

thank you sorin for the solution

andy
andy
Posts: 3

Re: Extract all the possible xpaths from a schema

Thu Sep 10, 2015 10:11 pm

I just got informed that this topic has been "approved by a moderator or administrator".
If this means that eventually it could be implemented in a future release, I have some more wishes in the meantime.

Instead of just the paths, I would like to have the cardinality of an element included. Something like:

root[1]
root[1]/provider[0..n]
root[1]/provider[0..n]/company[1]
root[1]/provider[0..n]/company[1]@name[req]
root[1]/provider[0..n]/company[1]@address[opt]
root[1]/recipient[1..3]
root[1]/recipient[1..3]/person[1]
root[1]/recipient[1..3]/person[1]@name[opt]

Meaning: root has minOccurs=1 and maxOccurs=1 (which is shortened to [1] instead of [1..1]). provider has minOccurs=0 and maxOccurs=unbounded etc. The Attribute @name has use=required and therefore gets a [req]. Obviously address has use=optional. In this shorthand form I would like to have the cardinalities always shown, even if they are relying on the defaults within the schema.

This would be helpful in a table with all the possible elements and attributes for discussing different aspects of the elements.
Would be nice if it's configurable whether the output is like this version or the first I presented.

Thanks in advance :wink:
andy
adrian
Posts: 2326

Re: Extract all the possible xpaths from a schema

Fri Sep 11, 2015 3:00 pm

Hi,

andy wrote:I just got informed that this topic has been "approved by a moderator or administrator".
If this means that eventually it could be implemented in a future release, I have some more wishes in the meantime.

This is a moderated forum, so the email you have received refers to your post being approved to be published on the forum. It's a bit strange that you would receive the message now, 6 months after your posted.

I cannot find a feature request logged for this on our issue tracking tool. I'm afraid this is not something that we are likely to implement into the application in the short term.

If I may ask, why not save a diagram from the Design view with the hierarchy of the XML structure?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
mhGLEIF
Posts: 40

Re: Extract all the possible xpaths from a schema

Wed Jan 25, 2017 3:35 pm

adrian wrote:
If I may ask, why not save a diagram from the Design view with the hierarchy of the XML structure?

Regards,
Adrian


The full XPATH listing would be exceptionally useful as a standard documentation item.

Those of us who use text based doc formats like DITA might want to import the list, make it into tables, annotate it etc. etc.

The XSLT should be very generic, right? And... shouldn't it be similar in concept to generating an instance?
adrian
Posts: 2326

Re: Extract all the possible xpaths from a schema

Wed Jan 25, 2017 7:22 pm

Hi,
The XSLT should be very generic, right? And... shouldn't it be similar in concept to generating an instance?
If you're wondering if implementing this is similar in concept to the implementation of the instance generator, it is, at least for traversing the schema. However, the instance generator from Oxygen is implemented in Java. There's no XSLT involved there, so it's not an easy rewrite, if that's what you're thinking of.

Oxygen is a Java application, so most of the actions, operations and tools are implemented in Java. There are very few actions (XML refactoring) that are implemented with XQuery Update.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests