Validating XML files against an XML schema
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Validating XML files against an XML schema
Basically, I've written up an XML file and an XSD and I want to see if the XML validates against the XSD. I've already validated my XSD file via the W3C validator.
Google seems to be pointing me to code snippets which can do this, but I just want a standalone program. So far I've found one, but it's only a trial version and you have to install .NET framework amonst other things before you attempt to install it.
Anyone got any programs to do this?
Thanks.
Also, I have no experience with XSL; but I'm wanting to output my XML file in a simple HTML table. Just two columns with element name in the left and value in the right. Shouldn't be too hard but I can't find any good information on the net anywhere. Can someone point me to a tutorial or anything about this?
Google seems to be pointing me to code snippets which can do this, but I just want a standalone program. So far I've found one, but it's only a trial version and you have to install .NET framework amonst other things before you attempt to install it.
Anyone got any programs to do this?
Thanks.
Also, I have no experience with XSL; but I'm wanting to output my XML file in a simple HTML table. Just two columns with element name in the left and value in the right. Shouldn't be too hard but I can't find any good information on the net anywhere. Can someone point me to a tutorial or anything about this?
Last edited by jayshields on Sat Mar 31, 2007 10:48 am, edited 1 time in total.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
What a coincidence... In searching for an online css compressor, I came across http://mathiasbynens.be/archive/2005/09/css-compressors Which shows what I was thinking about.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
libxml2 comes with the program xmllint
relaxNG example:
and btw php 5 can do it, tooUsage : xmllint [options] XMLfiles ...
[...]
--relaxng schema : do RelaxNG validation against the schema
--schema schema : do validation against the WXS schema
--schematron schema : do validation against a schematron
relaxNG example:
Code: Select all
<?php
$docA = DOMDocument::loadxml(
'<addressBook>
<card>
<name>John Smith</name>
<email>js@example.com</email>
</card>
<card>
<name>Fred Bloggs</name>
<email>fb@example.net</email>
</card>
</addressBook>');
$b = $docA->relaxNGValidateSource(
'<element name="addressBook" xmlns="http://relaxng.org/ns/structure/1.0">
<zeroOrMore>
<element name="card">
<element name="name">
<text/>
</element>
<element name="email">
<text/>
</element>
</element>
</zeroOrMore>
</element>');
var_dump($b);