Extract all the possible xpaths from a schema

This should cover W3C XML Schema, Relax NG and DTD related problems.
andy
Posts: 3
Joined: Mon Apr 13, 2015 12:34 am

Extract all the possible xpaths from a schema

Post by andy »

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: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Extract all the possible xpaths from a schema

Post by sorin_ristache »

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
Joined: Mon Apr 13, 2015 12:34 am

Re: Extract all the possible xpaths from a schema

Post by andy »

ok,

thank you sorin for the solution

andy
andy
Posts: 3
Joined: Mon Apr 13, 2015 12:34 am

Re: Extract all the possible xpaths from a schema

Post by andy »

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: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Extract all the possible xpaths from a schema

Post by adrian »

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: 43
Joined: Tue Jul 26, 2016 6:31 pm

Re: Extract all the possible xpaths from a schema

Post by mhGLEIF »

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: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Extract all the possible xpaths from a schema

Post by adrian »

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
Post Reply