Jump to content
Sign in to follow this  
id0

Schema for this XML

Recommended Posts

hi, i'm new to xml schema and i don't see a way to validate my xml file.here is 2 xml sample :

<liste>	<entete>		<colonne name="filename" />		<colonne name="size" />	</entete>	<item>		<filename>File 2</filename>		<size>14523</size>	</item>	<item>		<filename>File 3</filename>		<size>5901</size>	</item></liste>

and

<liste>	<entete>		<colonne name="filename" />		<colonne name="size" />		<colonne name="date" />		<colonne name="info" />	</entete>	<item>		<filename>File 2</filename>		<size>14523</size>		<date>01.01.01</date>		<info>new file</info>	</item>	<item>		<filename>File 3</filename>		<size>5901</size>		<date>02.02.02</date>		<info>old file</info>	</item></liste>

i need an XSD that can validate both xml and i don't see how to do that :) as u can see the attribute "name" on the "colonne" element gives the element name inside item element.any help is welcome, i'll continue searching for a solution on the web anyway.thks

Share this post


Link to post
Share on other sites

There is no way to do that in XML Schema 1.0. I think XML Schema 1.1 will provide such a facility.

Share this post


Link to post
Share on other sites

Well, you could have a basic, really loose schema against you could verify the document initially.Then, after analyzing the entete contents, you could generate a new schema with PHP, and validate against that. That's the first time I've ever thought about this, so doing it may not be as easy as it sounds, nor it will be efficient, but it sounds like something worth playing with.

Share this post


Link to post
Share on other sites

yep, i also thought about making an xsd in php using the "entete" content to check if all the <item> element are well done. I'll try that tomorrow since i 've worked on something else today :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...