Intro on Eclipse
Eclipse has two major bundles:
- Eclipse IDE for Java Developers
- Eclipse IDE for Java EE Developers.
Info here: http://www.eclipse.org/downloads/
The major difference is that Eclipse for JavaEE includes the Web Tools Platform (WTP). WTP has editors, designers, JavaEE perspective, new projects and so on.
I generally prefer to use the ‘Java’ perspective as opposed to the ‘JavaEE’ perspective, because the latter is too cluttered, but the one thing from WTP without which I cannot live is the XML editor. There are variations for XSL transformations and XML Schemas.
XML Schemas (XSD)
By default Eclipse can validate XML Schemas, because it has the schema for XSDs. Did you get this one? Let’s try again. XSD is a language written in xml that defines rules for xml files who want to conform to certain rules. This allows us to validate such files versus a schema. Finally XSD is also XML, so there is a special XSD Schema that defines how to write XSD Schemas. And the dog catches its tail.
XML Schema language is also defined in DTD. DTD is the predecessor of XSD.
Anyway, if you want to learn more, go to W3C Schools - the best place to learn XML, XSD, XSLT. This is also the official site of WWW Consortium (W3C) which handles the expert groups that define these standards.
Where is XSL.xsd?
XSL is written in xml, so there is an XSD Schema that defines how to write XSL files.
The schema for XSLT 2.0 (2007 revision) is here: http://www.w3.org/2007/schema-for-xslt20.xsd (the most up-to-date)
The DTD for XSLT 1.0 (1999 revision) is here: http://www.w3.org/TR/1999/REC-xslt-19991116.xml (I couldn’t find XSD for XSL 1.0, maybe because XSL 1.0 is too old)
So the only thing I need to do is put XSL.xsd in Eclipse?
Yes. Here’s how: go to Window –> Preferences and then to XML –> XML Catalogs:
(XML Catalogs are a very interesting topic. There’s an article on them in this blog here)
There are 3 ways to add an XML Schema to Eclipse
- Via an URL (as in the picture)
- Via a workspace location
- Via a file on the file system
How do we validate?
Via the "Validate" button on the context menu on any XML/XSL file.
7 thoughts on “How to make Eclipse validate XSL (and of course XML) files”
hmmm sounds very good, thank you man 🙂
These days I downloaded the STS - SpringSource Tools Suite (http://www.springsource.com/products/sts) . Looks very rich editor at first sight, but still I had no time to investigate it properly.
STS seems very nice, but currently I'm so short on time that I doubt that I'll be able to check it out. Thanks anyway 🙂
About MyEclipse - again, not enough time to do that. But MyEclipse is a commercial product.
If I was going to choose an IDE, that I have to pay for, I guess I'd try IntelliJ. I've used it before Eclipse became popoular and it was amazing. They say that it still is.
Added the XSD mentioned here PLUS the XSD for my xml file. If I validate, I get SUCCESS with NO ERRORS although the xml is obviously faulty.
Bug in Eclipser?
Although we have shown that Eclipse's current XML authoring support is pretty good, there are a two noteworthy limitations. The first is grammar and spell-checking. While these tools are commonplace in word-processing software, they do not yet exist for WTP's XML editor.