XML Schema and XML in one file?

user2881063

Can I put my XML and XML Schema in one file? Or the schema has to be separate file? Im new to XML

I have noticed from tutorials that they have an XML file (.xml) and a separate XML Schema file (.xsd). Am I understanding this correctly?

mhasan

Yes you can have xsd and xml in a same file such declaration is called as Inline Schema definition.

But as per general practice they are kept outside for many reasons, one of the very famous reason is:

  • Reusablility

Lets say you want to generate the sample xml/POJOs from the xsd for later.(Applies only for Java) (example JAXB)

Also as a best practice one should break the complex xsd into smaller xsd for easy to read and understand + flexibility of plugin the xsd required in a given case.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related