Jump to content
Sign in to follow this  
Wylbur

Locally Unique?

Recommended Posts

Hi all;I am trying to get straight the unique and key elements for XML Schema,especially with regards to the selector and field elements within.I'm unclear about selectors and fields, and I need to get this straight.Suppose I had an XML file with companies listed within functional groups.I have an element within each group with a unique field (to referenceeach particular group).I want to create a unique field within each company listing withineach group that would be unique only within that particular group.Would this be correct?:

		<xs:unique id="company_group_refs" name="company_group_refs">			<xs:selector xpath="root/all_companies/company_group"/>			<xs:field xpath="company_group_ref"/>		</xs:unique>		<xs:unique id="company_refs" name="company_refs">			<xs:selector xpath="root/all_companies/company_group"/>			<xs:field xpath="company/company_ref"/>		</xs:unique>

If so, could I condense the above to this?:

		<xs:unique id="company_refs" name="company_refs">			<xs:selector xpath="root/all_companies/company_group"/>			<xs:field xpath="company_group_ref"/>			<xs:field xpath="company/company_ref"/>		</xs:unique>

To reference any company name in particular, I want to be able togive an XPath expression like this: root/all_companies/company_group[company_group_ref=x1]/company[company_ref=x2]/nameWhere: x1 = the unique reference for the company group. x2 = the unique reference for the company within that group.What follows is an XML file excerpt that exemplifies this scenario:

	<all_companies>		<company_group>			<company_group_name>Cleaning</company_group_name>			<company_group_ref>1</company_group_ref>			<company>				<name>Ajax</name>				<company_ref>1</company_ref>			</company>			<company>				<name>Bloomburg</name>				<company_ref>2</company_ref>			</company>			<company>				<name>Morris</name>				<company_ref>3</company_ref>			</company>		</company_group>		<company_group>			<company_group_name>Electrical</company_group_name>			<company_group_ref>2</company_group_ref>			<company>				<name>Armstrong</name>				<company_ref>1</company_ref>			</company>			<company>				<name>Bloomburg</name>				<company_ref>2</company_ref>			</company>			<company>				<name>Zap Electrical</name>				<company_ref>3</company_ref>			</company>			<company>				<name>Morris</name>				<company_ref>4</company_ref>			</company>		</company_group>	</all_companies>

THANKS!!!

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...