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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoiding data replication in XML

Status
Not open for further replies.

0ddball

Technical User
Nov 6, 2003
208
GB
Hi folks. I'm trying to structure an XML document in the most efficient way possible and I have come accross a question I think I need answering. Here is my document structure - sorry no schema yet, this is an XLM doodle if you will.

Code:
<toolAdmin>
	<users>
		<user name="oddball">
			<tool name="demoTool">
				<linkTitle>TekTips Demo Data</linkTitle>
				<linkTarget>~/TekTips/demo.aspx</linkTarget>
				<data id="var1">lemon</data>
				<data id="var2">lime</data>
				<data ... /data>
			</tool>
			<tool ... /tool>
		</user>
		<user name="foobar">
			<tool name="demoTool">
				<linkTitle>TekTips Demo Data</linkTitle>
				<linkTarget>~/TekTips/demo.aspx</linkTarget>
				<data id="var1">lemon</data>
				<data id="var2">lime</data>
			</tool>
			<tool ... /tool>
		</user>
	</users>
	<roles .../*Same as users*/... /roles>
</toolAdmin>

The problem is I could have five roles and thirty users all using the Demo Tool with the same data and the same title and link. I don't want to have to replicate this data over and over again and I DO want to cascade updates to the data.

Is this where something like XPath would come in? I'm reading and writing this document with C# and the .NET 2.0 framework so solutions need to be implementable in said enviroment (prefereably without having to chase down custom libraries.

The easyest solution is to use a primary/foreign key system and two documents (tools.xml and access.xml, say). I just seem to feel that there should be a more graceful way of pulling that off in XML :)

Thanks for any time you give me ;)


Yet another unchecked rambling brought to you by:
Oddball
 
I'm sure this has been weighted pros & cons.
[tt]
<toolAdmin>
<tools>
<tool name="demoTool">
<linkTitle>TekTips Demo Data</linkTitle>
<linkTarget>~/TekTips/demo.aspx</linkTarget>
<data id="var1">lemon</data>
<data id="var2">lime</data>
</tool>
<tool name="demoTool2">
<etc>...</etc>
</tool>
<etc>...</etc>
</tools>
<users>
<user name="oddball">
<tool name="demoTool" />
<tool name="demoTool3" />
<tool name="etc..." />
</user>
<user name="foobar">
<tool name="demoTool" />
<tool name="demoTool2" />
<tool name="etc..." />
</user>
<etc>...</etc>
</users>
<roles>
<etc>...</etc>
</roles>
</toolAdmin>
[/tt]
Not very inventive. Just for the sake of responding.
 
:) That's the scheme I'm using at the moment. Guess you just confirmed that I'm doing it this way.

*wonders off to write some more XML handling code*


Yet another unchecked rambling brought to you by:
Oddball
 
Why use XML in the first place?

XML is for structured data, normally for interoperability between disparate systems.

This seems far more suited to a relational database.

Jon

"I don't regret this, but I both rue and lament it.
 
It's part of a hunk of data that is serialised backwards and forwards between a remote client and the server.

The actual file won't change that often and the tools are, as you say, detailed in a MySql database - as are the users and stuff.

I was just after the best way to represent this structure in an XML format.


Yet another unchecked rambling brought to you by:
Oddball
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top