Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One schema for multiple files

Status
Not open for further replies.

andybeeeeee

Programmer
Dec 9, 2002
17
GB
hi, i'm working on a project to make a kind of "universal schema" for a set of xml files and i need some help.

basically what happens is each file has exactly the same elements, but the attributes on one of the elements varies depending on which file it is. e.g.

Code:
 <connection cnid="cnAuthorisation" type="QUERY.ScriptingConnection" name="Authorisation" engine="QueryAxScripting.AxScripting" language="JScript">

is in one file and

Code:
 <connection cnid="cnAuthorisation" type="QUERYADO.ADOConnection" name="Authorisation" connectionstring="Provider=ADsDSOObject;Data Source=LDAP://EXONY;Mode=Read;Bind Flags=0" />

is in the next.

Is there one way of making my schema work so that i can write in xml code something along the lines of:

Code:
  if filename=abc, then attributes here, else if filename=xyz then attributes here...... and so on

appologies if this makes no sense or if i'm talkin utter jibberish, but i'm a java programmer not an xml one. i've been doin xml for 3 days!

thanks in advance
 
You would write your XSD to make those attributes optional:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:element name="Root">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="connection">
					<xs:complexType>
						<xs:attribute name="cnid" type="xs:string" use="required"/>
						<xs:attribute name="type" type="xs:string" use="required"/>
						<xs:attribute name="name" type="xs:string" use="required"/>
						<xs:attribute name="engine" type="xs:string" use="optional"/>
						<xs:attribute name="language" type="xs:string" use="optional"/>
						<xs:attribute name="connectionstring" type="xs:string" use="optional"/>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>
It would then validate both documents.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
hadnt thought of doing it that way. just not used to all this yet, teaching myself.

thanks alot for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top