XML & XML Schema

 Hi

 Can I use XML natively instead of a XML Schema.

The schema is very simple and I would like to see if it's possible to use just XML.

 

<!--W3C Schema generated by XMLSpy v2007 (http://www.altova.com)-->
<!--Please add namespace attributes, a targetNamespace attribute and import elements according to your requirements-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
	<xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
	<xs:element name="issue">
		<xs:complexType mixed="true">
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element ref="proposition"/>
			</xs:choice>
			<xs:attribute name="issueName" type="xs:string" use="required"/>
			<xs:attribute name="issueDate" type="xs:date" use="required"/>
		</xs:complexType>
	</xs:element>
	<xs:element name="proposition">
		<xs:complexType mixed="true">
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element ref="agreement"/>
				<xs:element ref="desagreement"/>
				<xs:element ref="clarificationrequest"/>
			</xs:choice>
			<xs:attribute name="propositionName" type="xs:string" use="required"/>
			<xs:attribute name="propositionDate" type="xs:date" use="required"/>
		</xs:complexType>
	</xs:element>
	<xs:element name="agreement">
		<xs:complexType mixed="true">
			<xs:attribute name="agreementName" type="xs:string" use="required"/>
			<xs:attribute name="agreementDate" type="xs:date" use="required"/>
		</xs:complexType>
	</xs:element>
	<xs:element name="desagreement">
		<xs:complexType mixed="true">
			<xs:attribute name="desagreementName" type="xs:string" use="required"/>
			<xs:attribute name="desagreementDate" type="xs:date" use="required"/>
		</xs:complexType>
	</xs:element>
	<xs:element name="clarificationrequest">
		<xs:complexType mixed="true">
			<xs:attribute name="clarificationrequestName" type="xs:string" use="required"/>
			<xs:attribute name="clarificationrequestDate" type="xs:date" use="required"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

I would like to do so for example:

<issue attribute="id" attribute="name" attribute="several" maxbound>

       <proposition>

           <agreement>sdafsdf</agreement>
           <disagreement>sdafsdf</disagreement>

       <proposition>
 

</issue>
 

 

tanks in advance 

0
aliefus
4/11/2008 9:01:59 PM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

8 Replies
1106 Views

Similar Articles

[PageSpeed] 53

 Sure, you can.

You do not need a schema to write xml. Schema's are used to validate XML

 

 


If I was helpful, please mark "answered" so I can get credit. Thanks!
0
Bonekrusher
4/11/2008 11:39:06 PM

 Thank you very much for your reply.

So

1-How should I define an attribute in XML for an element?

2-How should I say that an element has text?

3-How should I say that an element will either be repeated or not?

In fact I'm implementing in a project, a structured discussion website, the structure of the discussion is defined by a xml file which impose some rules to user if they want take part of the discussion.

Is xml suffisient, supponsing that the model is very small and there are only strings?

Thanks

Ali 

Ali
 

0
aliefus
4/12/2008 12:19:56 AM

Hi,


If you are defining an element, it's type and content you can use either a DTD or Schema. If you are creating a web site which has users input info then you dont need either. You can build in validation through ASP.NET control validation. In asp.net you can use regular expressions to make sure that a user enters text when they input data.

HTH

Regards 


If I was helpful, please mark "answered" so I can get credit. Thanks!
0
Bonekrusher
4/12/2008 11:46:53 AM

Thank you

This is a very good Idea, the xml file would serves as a validator.

This project is used for a special kind of forum or discussion. It's structure is defined by my professor, and he would like to be able by changing the model, changing the structure of the site.

Suppose I have the XML file:

<issue date="01.01.1985" name="x">Should mobile be forbidden at school?


    <propostition date="xx.xx.xxxx" name="y">It should be just limited

           <agreement date="01.01.2008" name="mark">I agree with this porposition</agreement>

           <disagreement date="01.05.2008" name="hussein">doesn't solve problems</disagreement>

    </proposition> 

</issue> 

At this level a user can add new ISSUE, other user want to make a PROPOSITION for an ISSUE, another user would like to say I agree(AGREEMENT) with this solution, and finally another user disagree with the PROPOSITION.

Now if I want to change my model for adding a child element to PROPOSITION, for example <REQUEST CLARIFICATION></CLARIFICATION REQUEST> I should change all my interface to add the new element.

That's what I'm looking for, finding the easiest way to modify my web interface according to the model.

I would appreciate any help

Ali
 

0
aliefus
4/12/2008 12:20:26 PM

 Are you using ASP.NET?


If I was helpful, please mark "answered" so I can get credit. Thanks!
0
Bonekrusher
4/12/2008 1:00:33 PM

Yes of course. Why do you ask it?

0
aliefus
4/12/2008 1:50:51 PM

 Because you can create a form with fields that when the user clicks "submit" you modify or append your XML.

Google "modify XML asp.net"

 


If I was helpful, please mark "answered" so I can get credit. Thanks!
0
Bonekrusher
4/12/2008 8:43:54 PM

 Can XForms been used in my case (generating controls depending on xml schema)?

Otherwise searched on Google for  "modify XML asp.net" and there they talk about changing the xml file from webform, but my question is how to create or generate fields/control from a XML Schema.

 

Look at example I gave above, suppose I have an ASPX page in which I added controls according to the XML Schema, if I modify my schema, I have to go and manually add control to keep update my page according to the schema.

 

Thanks 

0
aliefus
4/13/2008 3:30:36 PM
Reply: