wood burning stoves 2.0*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes help in testing xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "help in testing xml" Watch "help in testing xml" New topic
Author

help in testing xml

nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Hi,

I want to test my knowledge with xml and xsd. Do i have to use javacode to validate my xml against xsd or there is anyother way?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
No you do not have to use Java - both Eclipse and NetBeans contain XML editors which can validate an XML document against its schema.
If you want to be more exclusive, there are special XML editors, like Oxygen XML (http://www.oxygenxml.com/), that also can validate XML documents against XML schemas.
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Thank you very much
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
is there a way to validate xml using xsd in eclipse? i was able to create xsd from editor but i am not able to validate. any help is appreciated.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
nitin pokhriyal wrote:is there a way to validate xml using xsd in eclipse? i was able to create xsd from editor but i am not able to validate. any help is appreciated.

Have you tried right-clicking in the editor window of the XSD file and selecting validate?
Best wishes!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
Thank Ivan for your help, I can validate xsd but problem is that i am not able to validate my xml data against the xsd. I will try again may be i am not using correct format. I will post my example, i think that will easy for other to reply
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
here is my xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ibm.com" xmlns="http://www.ibm.com">
<xsd:complexType name="AddressType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="MyAddress" type="AddressType"></xsd:element>
</xsd:schema>

and here is my xml
<?xml version="1.0"?>
<x:MyAddress xmlns:x="http://www.ibm.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/NewXMLSchema.xsd ">
<aname>Peter Smith</aname>
</x:MyAddress>

so this xml is wrong but how do i validate xml against above mentioned xsd in eclipse.
In eclipse i just got warning but if i don't close tags or start/end tag does not match then i got error. I want to validate if the tags are missing or may be tag not at all defined in xsd as i am trying "aname" tag but in xsd "name" is defined.

Thanks
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
If you want the validator to be able to find the XML schema, you must specify its location in the value of the schemaLocation attribute.
If the schema is located in the same directory as the XML file, then the specification of the schema location would look something like this:

Hint: Look at row 3!
Hope this helps!
nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
IVAN thank you very much, It worked now.


Here is xml which validated successfully. if i change any tag it gives validation error(Though it was not understable).

<?xml version="1.0"?>
<x:MyAddress xmlns:x="http://www.ibm.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com NewXMLSchema.xsd ">
<name>Peter Smith</name>
</x:MyAddress>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help in testing xml
 
Similar Threads
validating xml with xsd
xml and JaxB without xsd
XML Editor
XML Schema Help
Problem with SOAP