Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Splitting an XML file

 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an xml file for look up of datasources. It has all the necessary entries for each of its datasources. How can I split this into two files and keep only login details in a separate file and access those from this file? How do I refernce only those two properties of user name and password which are in the second file from the first file?


Thanks,

Vasu
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you wanna use DOM or XSLT ?
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the entry of a datasource in the xml file. Now I want the user name and password propeties to be taken out of this file, put in another file which is more secure and acess those parameters from this file.



Thanks,

Vasu
[ October 27, 2004: Message edited by: vasu maj ]
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well? Nobody has done anything like this before?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use XML entities to read the username and password from a separate file a bit like this. It would, however, require you to put the username and password into separate files unless you'd decide to externalize the whole
    <parameter>
        <name>username</name>
        <value>user</value>
    </parameter>
    <parameter>
        <name>password</name>
        <value>password</value>
    </parameter>
into an external file and include that inside the <Resource/> element

Another option could be to generate the resulting configuration file with XSLT and using the document() function and XPath to locate the username and password for each DataSource. This would allow placing all DataSource usernames/passwords into a single file but would also add complexity into the whole setup since you're not dealing with "static" files anymore but using XSL transformation instead.
 
vasu maj
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks but I didn't understand why I can't put two properties ( username and password) into one file and include the file. Also how are the properties read if some properties of the same datasource are in the original file and others are in a different file? Do I need to define a resource with the same names as in the original file with only the two properties in the included file?


Thanks
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vasu maj:
Thanks but I didn't understand why I can't put two properties ( username and password) into one file and include the file.

This is what Lasse explained you how to do it.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vasu maj:
Thanks but I didn't understand why I can't put two properties ( username and password) into one file and include the file.

Because the XML entity inclusion method includes the whole contents of the referred file, not just parts of it.

In other words, you'd need to have these 3 files:
datasource-username.txt
datasource-password.txt
datasource.xml

with the following contents:

datasource-username.txt

datasource-password.txt

datasource.xml


This XML document, when parsed by an XML parser, would be equivalent to the following document:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic