Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0
This is the forum to discuss the Wrox book XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition by Michael Kay; ISBN: 9780470192740
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 11th, 2012, 04:38 AM
Authorized User
Points: 141, Level: 2
Points: 141, Level: 2 Points: 141, Level: 2 Points: 141, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default Reading a schema's facets using Java

Hello.

We have various schema definitions that contain various facets such as xs:annotations, xs:restrictions. I would like to be able to load one of these files and extract this information so I could use an annotation's content as a tooltip or populate a combo box list with the enumerations from a restriction for example.

But to be honest I'm not to sure where to start? I guess it could be done using XPath but I suspect that isn't the correct approach. My processing engine of choice is Saxon 9, so does anyone have a link they could share or some pointers to documentation where I can get a head start.

Thank you.
--
William
Reply With Quote
  #2 (permalink)  
Old October 11th, 2012, 05:11 AM
mhkay's Avatar
Wrox Author
Points: 18,252, Level: 58
Points: 18,252, Level: 58 Points: 18,252, Level: 58 Points: 18,252, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,929
Thanks: 0
Thanked 281 Times in 276 Posts
Default

Processing raw schema documents using XPath isn't easy because there are so many different ways of writing effectively the same schema, e.g. using named types or anonymous types, included documents, named model groups and attribute groups, etc. You may be better off trying to get the information from the compiled schema made available by a schema processor. Xerces for example offers an API for access to schema information. Saxon will output the compiled schema in an easy-to-process XML form called SCM - though unfortunately this does not include annotations.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
WilliamYou (October 11th, 2012)
  #3 (permalink)  
Old October 11th, 2012, 05:35 AM
Authorized User
Points: 141, Level: 2
Points: 141, Level: 2 Points: 141, Level: 2 Points: 141, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Thank you for the reply, I can live without the annotations I guess and the SCM option seems like a good place to start. I've looked in the saxon-resources9-4 and found an scm directory but I see no Java examples in how to get to that point (unless I've missed it).

I would be greatful if you (or anyone) could provide me with a link to a Java sample to help me kick start my learning.

--
William
Reply With Quote
  #4 (permalink)  
Old October 11th, 2012, 06:09 AM
mhkay's Avatar
Wrox Author
Points: 18,252, Level: 58
Points: 18,252, Level: 58 Points: 18,252, Level: 58 Points: 18,252, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,929
Thanks: 0
Thanked 281 Times in 276 Posts
Default

I'm afraid there's not as much documentation as you would like. The documentation at

http://www.saxonica.com/documentatio...processing/scm

explains how to generate an SCM file, and the schema scmschema.xsd describes the meaning of the data found in the elements and attributes of an SCM file (by reference to the description of schema components in the W3C specification). After that, you're pretty much on your own. Processing the SCM document is much like processing any other XML document. I would recommend doing it in XSLT or XQuery rather than in Java, but that's up to you.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
WilliamYou (October 11th, 2012)
  #5 (permalink)  
Old October 11th, 2012, 06:36 AM
Authorized User
Points: 141, Level: 2
Points: 141, Level: 2 Points: 141, Level: 2 Points: 141, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Hello and thanks for that. I've read this and I'm wiser now than I was 10 minutes ago. You're recommendation for processing the SCM using XSLT | XQuery is confusing me I was going to use the s9api and use XPath to extract what I needed.

But if the truth be told what I would really like to do is generate an XForms form and display it in my applet, but with my limited understanding of this I don't think I'm able to "submit" the resulting tree back into my applet, assuming I can even host it.

--
William
Reply With Quote
  #6 (permalink)  
Old October 11th, 2012, 07:29 AM
mhkay's Avatar
Wrox Author
Points: 18,252, Level: 58
Points: 18,252, Level: 58 Points: 18,252, Level: 58 Points: 18,252, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,929
Thanks: 0
Thanked 281 Times in 276 Posts
Default

SCM and XForms are both XML formats, so converting one to the other sounds like a natural task for XSLT, but of course if you prefer to tackle it using Java+XPath, that's your prerogative.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
WilliamYou (October 11th, 2012)
  #7 (permalink)  
Old October 11th, 2012, 08:56 AM
Authorized User
Points: 141, Level: 2
Points: 141, Level: 2 Points: 141, Level: 2 Points: 141, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mhkay View Post
SCM and XForms are both XML formats, so converting one to the other sounds like a natural task for XSLT, but of course if you prefer to tackle it using Java+XPath, that's your prerogative.
Of course using XSLT for this is a no-brainer. But what I neglected to mention is that these forms would be created on demand within the applet hence the use of s9api / Java.

--
William
Reply With Quote
  #8 (permalink)  
Old October 11th, 2012, 09:14 AM
mhkay's Avatar
Wrox Author
Points: 18,252, Level: 58
Points: 18,252, Level: 58 Points: 18,252, Level: 58 Points: 18,252, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,929
Thanks: 0
Thanked 281 Times in 276 Posts
Default

Have you considered the possibility of using Saxon-CE (XSLT 2.0 in the browser) as an alternative to using a Java applet?

(The documentation page that I pointed to earlier is rendered using Saxon-CE, so you've already been using it without realising it...)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
The Following User Says Thank You to mhkay For This Useful Post:
WilliamYou (October 11th, 2012)
  #9 (permalink)  
Old October 11th, 2012, 09:47 AM
Authorized User
Points: 141, Level: 2
Points: 141, Level: 2 Points: 141, Level: 2 Points: 141, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 35
Thanks: 18
Thanked 0 Times in 0 Posts
Default

As elegant as that sounds to be honest I don't think I can, as I have to be able to allow the system (comprised of 3 Applets) to work offline (i.e. no Internet connection), but this isn't the main issue.

My intention is to generate an XForms form from a Schema definition, the schema used depends on the option selected by the user. This form is then pushed into a named target on the frameset hosting the applet.

The user then completes the form and clicks the submit button. Now normally this would go back to the server but I don't want that so I was going to listen on an arbitrary free port and use a submission URI of tcp://127.0.0.1:PORTNO for the form's post method.

As I've 'trapped' the submission of the XML I can now save it locally and pass it along to another applet via another socket or Active MQ where the XML will get 'processed'.

P.S. All of the applets are digitally signed.

P.P.S Having said that you've given me a really good idea. :-)

--
William
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
To call a java class from javascipt and pass a variable to the java servelet too prithagupta Java Basics 4 March 9th, 2013 07:39 AM
java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java Hot Nixxxter Java Basics 6 January 11th, 2012 11:36 AM
Java SE Development Kit and Eclipse IDE for Java EE? Droider BOOK: Beginning Android Application Development 1 October 7th, 2011 08:42 AM
reading excel file in java uttam.mca Pro JSP 1 July 14th, 2006 07:29 PM
Reading word document from a java application meenu Pro JSP 1 March 22nd, 2004 04:11 AM



All times are GMT -4. The time now is 02:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.