Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JNLP xsd schema

344 views
Skip to first unread message

Roedy Green

unread,
Jul 22, 2007, 11:24:01 PM7/22/07
to
I have a JNLP 1.0 xsd schema on my website which can be used to
validate JNLP files.
http://mindprod.com/jgloss/javawebstart.html#VALIDATION

I would like to update that with a JNLP 1.5+ schema. Google seems to
think nobody but me has a schema. Is here one? I could I suppose
write one, but I would be nervous since I don't have language lawyer
genes, and I would hate to send people astray misinterpreting the
spec.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Andrew Thompson

unread,
Jul 23, 2007, 4:21:48 AM7/23/07
to
Roedy Green wrote:
>I have a JNLP 1.0 xsd schema on my website which can be used to
>validate JNLP files.
>http://mindprod.com/jgloss/javawebstart.html#VALIDATION
>
>I would like to update that with a JNLP 1.5+ schema.

Not to my knowledge. Sun provides a DTD with the JNLP
Spec. documents.. umm.. where-is-it..
<http://www.google.com/search?as_filetype=dtd&as_sitesearch=java.sun.com>
U-yup, there.. 6th link..
<http://java.sun.com/dtd/JNLP-6.0.dtd>
though technically that is for 6, not 5.

>..Google seems to


>think nobody but me has a schema.

Google also finds my two XSD files at JavaSaver.
<http://www.google.com/search?q=+site%3Ajavasaver.com+filetype%3Axsd>

Maybe there are no logical links (as parsed by Google)
to other 'naked' DTD's and XSD's (vague shrug).

>..Is here one? I could I suppose


>write one, but I would be nervous since I don't have language lawyer
>genes, and I would hate to send people astray misinterpreting the
>spec.

.issue a version with 'all disclaimers - use at own risk'
in the comments at the top, and be done with it - is
my 'IANAL response'.

As an aside, I had also been thinking of making an XSD
of the JNLP DTD, since I know there are tools which will
convert a DTD to a simple XSD (I don't know off-hand
what they are). I developed a DTD for the XScreenSaver
GUI config. files, somebody converted it to a XSD, and
we quickly abandoned the DTD and instead refined the
XSD.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200707/1

Thomas Fritsch

unread,
Jul 23, 2007, 5:50:58 AM7/23/07
to
Roedy Green wrote:
> I have a JNLP 1.0 xsd schema on my website which can be used to
> validate JNLP files.
> http://mindprod.com/jgloss/javawebstart.html#VALIDATION
Roedy, you probably mean this link:
http://mindprod.com/jgloss/jnlp.html#VALIDATION

--
Thomas

Roedy Green

unread,
Jul 23, 2007, 10:24:24 AM7/23/07
to
On Mon, 23 Jul 2007 09:50:58 GMT, Thomas Fritsch
<i.dont.l...@invalid.com> wrote, quoted or indirectly quoted
someone who said :I changed the link shortly after I posted.. I have moved the JNLP
stuff out of the java webstart.html link.

Roedy Green

unread,
Jul 23, 2007, 2:40:16 PM7/23/07
to
On Mon, 23 Jul 2007 03:24:01 GMT, Roedy Green
<see_w...@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>I would like to update that with a JNLP 1.5+ schema. Google seems to


>think nobody but me has a schema. Is here one? I could I suppose
>write one, but I would be nervous since I don't have language lawyer
>genes, and I would hate to send people astray misinterpreting the
>spec.

I got an email from Sun. They said they post a DTD for 1.5 and 6, but
no xsd or other advanced schemas. I have the URLS at
http://mindprod.com/jgloss/jnlp.html

Roedy Green

unread,
Jul 23, 2007, 3:13:31 PM7/23/07
to
On Mon, 23 Jul 2007 08:21:48 GMT, "Andrew Thompson" <u32984@uwe>

wrote, quoted or indirectly quoted someone who said :
>As an aside, I had also been thinking of making an XSD
>of the JNLP DTD, since I know there are tools which will
>convert a DTD to a simple XSD (I don't know off-hand
>what they are)
Perhaps you might create a tool that takes an EXAMPLE XML file with
all possible options, and it creates an XSD you then polish by hand.

Piotr Kobzda

unread,
Jul 23, 2007, 8:11:15 PM7/23/07
to
Roedy Green wrote:

> I got an email from Sun. They said they post a DTD for 1.5 and 6, but
> no xsd or other advanced schemas. I have the URLS at
> http://mindprod.com/jgloss/jnlp.html

Interestingly, theirs DTD for 6 seems to be invalid (in both, Sun site,
and in Appendix C of JNLP specification).

Corrections needed (my guess):

<!ELEMENT update>
should be:
<!ELEMENT update EMPTY>

and:

<!ELEMENT shortcut (desktop? menu?)>
should be:
<!ELEMENT shortcut (desktop?, menu?)>


DTD for 1.5 seems to be correct.


If you want convert them automatically to XSD (as Andrew suggested
earlier) some tools you can find there:
http://www.w3.org/XML/Schema#Tools

(about a year ago I successfully used XMLSpy for that)


However, instead of validating against XSD, there is also possibility to
validate JNLP file against DTD directly. That usually requires an
addition (or rewriting) of DTD in that file. But hopefully, we can
perform that on the fly -- an example using StAX (from Java 6) is below.


piotr


import java.io.*;

import javax.xml.parsers.*;
import javax.xml.stream.*;
import javax.xml.stream.events.*;

import org.xml.sax.*;
import org.xml.sax.helpers.*;

public class ValidateJNLP {

public static void main(String[] args) throws Exception {
File input_file = new File(args[0]);
File dtd_file = new File("JNLP-6.0.dtd");


// rewrite input file...

StringWriter rewrite_out = new StringWriter();

XMLInputFactory xif = XMLInputFactory.newInstance();
XMLOutputFactory xof = XMLOutputFactory.newInstance();
XMLEventFactory xef = XMLEventFactory.newInstance();

XMLEventReader er = xif.createXMLEventReader(
new FileReader(input_file));
XMLEventWriter ew = xof.createXMLEventWriter(rewrite_out);

while (er.hasNext()) {
XMLEvent e = er.nextEvent();

if (e.isStartElement()) {
// creatre new DTD
DTD dtd = xef.createDTD("<!DOCTYPE jnlp"
+ " SYSTEM \"" + dtd_file.toURI() + "\">");
ew.add(dtd);
ew.add(e);
break;
} else if (e instanceof DTD) {
// skip original DTD
System.err.println("original DTD skipped!");
} else {
// write event as is
ew.add(e);
}
}
// write all left input events...
ew.add(er);
ew.flush();
ew.close();

// System.out.println(rewrite_out.toString());
StringReader rewritten_in
= new StringReader(rewrite_out.toString());


// validate...

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(true);

SAXParser sp = spf.newSAXParser();

InputSource is = new InputSource(rewritten_in);
sp.parse(is, new JNLPErrorHandler());
}

}

class JNLPErrorHandler extends DefaultHandler {

@Override
public void warning(SAXParseException exception) throws SAXException {
System.err.println(exception);
}

@Override
public void error(SAXParseException exception) throws SAXException {
System.err.println(exception);
}

@Override
public void fatalError(SAXParseException exception) throws
SAXException {
System.err.println(exception);
}
}

Andrew Thompson

unread,
Jul 23, 2007, 10:27:18 PM7/23/07
to
Piotr Kobzda wrote:
>> I got an email from Sun. They said they post a DTD for 1.5 and 6, but
>> no xsd or other advanced schemas. I have the URLS at
>> http://mindprod.com/jgloss/jnlp.html
>
>Interestingly, theirs DTD for 6 seems to be invalid (in both, Sun site,
>and in Appendix C of JNLP specification).

<grumble>Unfortunate, but not that surpsising for Sun.</grumble>
..
>If you want convert them automatically to XSD ... some tools you can find there:
>http://www.w3.org/XML/Schema#Tools

Thanks. I never look forward to the initial work of
transforming DTD -> XSD.

>(about a year ago I successfully used XMLSpy for that)
>
>However, instead of validating against XSD, there is also possibility to
>validate JNLP file against DTD directly.

Sure there is, but why would you bother?
XSD can check eveything specified in a DTD,
plus a whole lot more besides.

Andrew Thompson

unread,
Jul 23, 2007, 11:33:20 PM7/23/07
to
Piotr Kobzda wrote:
..

>Interestingly, theirs DTD for 6 seems to be invalid (in both, Sun site,
>and in Appendix C of JNLP specification).
>
>Corrections needed (my guess):

Your guesses seem pretty solid to me.

><!ELEMENT update>
>should be:
><!ELEMENT update EMPTY>

xss2dtd would not parse the file before I added that, and..

><!ELEMENT shortcut (desktop? menu?)>

.leads to..
<xs:sequence>
<xs:element minOccurs="0" ref="desktop? menu"/>
</xs:sequence>

.which appears completely bogus to me, and
more like an error on the part of xss2dtd.

>should be:
><!ELEMENT shortcut (desktop?, menu?)>

<xs:sequence>
<xs:element minOccurs="0" ref="desktop"/>
<xs:element minOccurs="0" ref="menu"/>
</xs:sequence>

.that looks more like it
..
>..some tools you can find there:
>http://www.w3.org/XML/Schema#Tools

I clicked the link to ..

>(about a year ago I successfully used XMLSpy for that)

.XMLSpy but while waiting for the page to load, saw
dtd2xss, looked at their page, 'liked the price', and had
it mostly donwloaded before I decided I could not be
bothered waiting any longer for the other page to arrive. ;-)

Here is the XSD that xss2dtd produces, based on Piotr's
corrections, above - with a comment in the header
. It's only 270 odd lines..

<!--
Adapted from Sun's DTD..
jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Discriptor 6.0//EN"
"http://java.sun.com/dtd/JNLP-6.0.dtd"

Oh.. and note that should be Descriptor, not (bloody) Discriptor.
-->
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" name="jnlp">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="information"/>
<xs:element minOccurs="0" ref="security"/>
<xs:element minOccurs="0" ref="update"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="resources"/>
<xs:choice>
<xs:element ref="application-desc"/>
<xs:element ref="applet-desc"/>
<xs:element ref="component-desc"/>
<xs:element ref="installer-desc"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="spec" type="xs:string"/>
<xs:attribute name="version" type="xs:string"/>
<xs:attribute name="codebase" type="xs:string"/>
<xs:attribute name="href" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element ref="title"/>
<xs:element ref="vendor"/>
<xs:element minOccurs="0" ref="homepage"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="description"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="icon"/>
<xs:element minOccurs="0" ref="offline-allowed"/>
<xs:element minOccurs="0" ref="shortcut"/>
<xs:element minOccurs="0" ref="association"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="related-content"/>
</xs:sequence>
<xs:attribute name="os" type="xs:string"/>
<xs:attribute name="arch" type="xs:string"/>
<xs:attribute name="platform" type="xs:string"/>
<xs:attribute name="locale" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="kind">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="one-line"/>
<xs:enumeration value="short"/>
<xs:enumeration value="tooltip"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="height" type="xs:string"/>
<xs:attribute name="kind" type="xs:string"/>
<xs:attribute name="depth" type="xs:string"/>
<xs:attribute name="size" type="xs:string"/>
</xs:complexType>
<xs:complexType/>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="all-permissions"/>
<xs:element minOccurs="0" ref="j2ee-application-client-permissions"/>
</xs:sequence>
</xs:complexType>
<xs:complexType/>
<xs:complexType/>
<xs:complexType>
<xs:attribute default="timeout" name="check">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="always"/>
<xs:enumeration value="timeout"/>
<xs:enumeration value="background"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute default="always" name="policy">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="always"/>
<xs:enumeration value="prompt-update"/>
<xs:enumeration value="prompt-run"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element ref="java"/>
<xs:element ref="j2se"/>
<xs:element ref="jar"/>
<xs:element ref="nativelib"/>
<xs:element ref="extension"/>
<xs:element ref="property"/>
<xs:element ref="package"/>
</xs:choice>
<xs:attribute name="os" type="xs:string"/>
<xs:attribute name="arch" type="xs:string"/>
<xs:attribute name="locale" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="resources"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required"/>
<xs:attribute name="href" type="xs:string"/>
<xs:attribute name="initial-heap-size" type="xs:string"/>
<xs:attribute name="max-heap-size" type="xs:string"/>
<xs:attribute name="java-vm-args" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="resources"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string" use="required"/>
<xs:attribute name="href" type="xs:string"/>
<xs:attribute name="initial-heap-size" type="xs:string"/>
<xs:attribute name="max-heap-size" type="xs:string"/>
<xs:attribute name="java-vm-args" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string"/>
<xs:attribute default="false" name="main">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute default="eager" name="download">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="eager"/>
<xs:enumeration value="lazy"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="size" type="xs:string"/>
<xs:attribute name="part" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:attribute name="href" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:string"/>
<xs:attribute default="eager" name="download">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="eager"/>
<xs:enumeration value="lazy"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="size" type="xs:string"/>
<xs:attribute name="part" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="ext-download"/>
</xs:sequence>
<xs:attribute name="version" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType>
<xs:attribute name="ext-part" type="xs:string" use="required"/>
<xs:attribute default="eager" name="download">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="lazy"/>
<xs:enumeration value="eager"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="part" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="part" type="xs:string" use="required"/>
<xs:attribute default="false" name="recursive">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="argument"/>
</xs:sequence>
<xs:attribute name="main-class" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="param"/>
</xs:sequence>
<xs:attribute name="documentbase" type="xs:string"/>
<xs:attribute name="main-class" type="xs:string" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="width" type="xs:string" use="required"/>
<xs:attribute name="height" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType/>
<xs:complexType>
<xs:attribute name="main-class" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="desktop"/>
<xs:element minOccurs="0" ref="menu"/>
</xs:sequence>
<xs:attribute default="true" name="online">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType/>
<xs:complexType>
<xs:attribute name="submenu" type="xs:string"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="description"/>
<xs:element minOccurs="0" ref="icon"/>
</xs:sequence>
<xs:attribute name="extensions" type="xs:string" use="required"/>
<xs:attribute name="mime-type" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="title"/>
<xs:element minOccurs="0" ref="description"/>
<xs:element minOccurs="0" ref="icon"/>
</xs:sequence>
<xs:attribute name="href" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>

I might be looking to put some form of this up on my
site in the future, but it has not even been taken for a
test drive, yet.

HTH

Andrew Thompson

unread,
Jul 23, 2007, 11:40:20 PM7/23/07
to
Andrew Thompson wrote:
..
>xss2dtd would not parse ...

Oh.. and note that every reference to xss2dtd in that
post, should actually have been a reference to dtd2xss
(ya' complete moron, Andrew).

In fact, it seems they've dropped the final 's' - 'dtd2xs'.
Maybe because it sounds 'kewl' (Shop till you drop?
DTD 2 XS!). Their site is..
<http://www.lumrix.net/dtd2xs.php>

Piotr Kobzda

unread,
Jul 24, 2007, 5:13:53 AM7/24/07
to
Andrew Thompson wrote:
> Piotr Kobzda wrote:

>> However, instead of validating against XSD, there is also possibility to
>> validate JNLP file against DTD directly.
>
> Sure there is, but why would you bother?

Because DTD is only officially available definition?

> XSD can check eveything specified in a DTD,
> plus a whole lot more besides.

Yes, XSD can do a lot more than DTD can, but unfortunately, not all what
DTD can do, is possible with XSD. For example, there is internal and
external DTD, and a lot of tricky features of DTD possible, e.g.
entities, definitions overriding, etc., which by design are not a
features of XSD. DTD is tightly bound into XML document parsing, and,
in general, can not be converted into fully equivalent XSD. Of course,
as we know, there is nothing tricky in DTD for JNLP, and assuming
non-tricky use of it, we can easily convert it into equivalent XSD. But
since JNLP is defined using DTD only, we do not need any extra features
that XSD offer (using them, we could possibly change the definition).
Moreover, to use XSD, we must in our own risk convert the original DTD
(there is no support for that in standard Java), which puts additional
layer, possibly error prone, into validation process. As the result,
making the validation less trust-worthy than direct use of the definition.


piotr

Piotr Kobzda

unread,
Jul 24, 2007, 5:27:41 AM7/24/07
to
Andrew Thompson wrote:

> Here is the XSD that xss2dtd produces, based on Piotr's
> corrections, above - with a comment in the header
> . It's only 270 odd lines..

Possibly "copying & pasting" it caused loosing of some important parts
of the XSD -- now it's invalid (69 errors :) ).

In addition to the w3c's list of tools, you may find useful the on-line
utilities at:
http://www.hitsw.com/xml_utilites/

The "DTD to XML Schema" tool seems to produce correct XSD equivalents
for all DTDs I tried it with, all in just a few clicks.


piotr

Andrew Thompson

unread,
Jul 28, 2007, 10:20:59 PM7/28/07
to
Piotr Kobzda wrote:
>> Here is the XSD that xss2dtd produces, based on Piotr's
>> corrections, above - with a comment in the header
>> . It's only 270 odd lines..
>
>Possibly "copying & pasting" it caused loosing of some important parts
>of the XSD -- now it's invalid (69 errors :) ).

Perhaps! Whatever happened, it happened to my local
copy as well. :-(

>In addition to the w3c's list of tools, you may find useful the on-line
>utilities at:
>http://www.hitsw.com/xml_utilites/
>
>The "DTD to XML Schema" tool seems to produce correct XSD equivalents
>for all DTDs I tried it with, all in just a few clicks.

Spot on! I'm now working with an XSD developed
using that page* and based upon the corrections you
suggested to Sun's DTD. It is the first time I've been
able to see a 'valid JNLP' (checking against a valid XSD)
message in a little validator I'm putting together.

Once I've finished checking and refining the XSD, I'll
upload it and give the URL.

* I was also considering trying to download Altova's
'trial ware' packs - but at 100 meg, that blows my
entire month's limit of downloads before being
bandwidth throttled!

0 new messages