473,569 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

representing a directory structure in XML


I'm a relative newbie, interested in storing the information from several
server directories and subdirectories in XML so that I can present it
selectively using XSL (all files updated today or last MOnday, files from
several drirectories in alphabetical order, things like that).

To represent directories and subidrectories, is it advisable to nest the
same element:

<directory>
<directory>
<directory>

or is there a better way?

--
"For it is only of the new one grows tired. Of the old one never tires."
-- Kierkegaard, _Repetition_

James Owens, Ottawa, Canada
Nov 11 '05 #1
8 2576
James Owens wrote:
I'm a relative newbie, interested in storing the information from several
server directories and subdirectories in XML so that I can present it
selectively using XSL (all files updated today or last MOnday, files from
several drirectories in alphabetical order, things like that).

To represent directories and subidrectories, is it advisable to nest the
same element:

<directory>
<directory>
<directory>

or is there a better way?

--
"For it is only of the new one grows tired. Of the old one never tires."
-- Kierkegaard, _Repetition_

James Owens, Ottawa, Canada

You can create your own xml structure, so
you can represent directories and subdirectories in many ways.

lik this

<dir>
<dir name="directory 1">
</dir>
<dir name="dir2">
<dir name="subdir"/>
</dir>
</dir>
or like this:

<dir name="/directory1"/>
<dir name="/dir2"/>
<dir name="/dir2/subdir"

There are many ways.
Nov 11 '05 #2
Tjerk Wolterink wrote:
James Owens wrote:
I'm a relative newbie, interested in storing the information from
several server directories and subdirectories in XML so that I can
present it selectively using XSL (all files updated today or last
MOnday, files from several drirectories in alphabetical order, things
like that).

To represent directories and subidrectories, is it advisable to nest
the same element:

<directory>
<directory>
<directory>

or is there a better way?

--
"For it is only of the new one grows tired. Of the old one never
tires." -- Kierkegaard, _Repetition_

James Owens, Ottawa,
Canada

You can create your own xml structure, so
you can represent directories and subdirectories in many ways.

lik this

<dir>
<dir name="directory 1">
</dir>
<dir name="dir2">
<dir name="subdir"/>
</dir>
</dir>
or like this:

<dir name="/directory1"/>
<dir name="/dir2"/>
<dir name="/dir2/subdir"

There are many ways.


True, but hard-naming subdir or directory{1|2.. .} is a case of premature
binding. I think the nesting of directory as originally suggested is
probably fine for this purpose.

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Nov 23 '05 #3
Peter Flynn wrote:
Tjerk Wolterink wrote:

James Owens wrote:
I'm a relative newbie, interested in storing the information from
several server directories and subdirectories in XML so that I can
present it selectively using XSL (all files updated today or last
MOnday, files from several drirectories in alphabetical order, things
like that).

To represent directories and subidrectories, is it advisable to nest
the same element:

<directory>
<directory>
<directory>

or is there a better way?

--
"For it is only of the new one grows tired. Of the old one never
tires." -- Kierkegaard, _Repetition_

James Owens, Ottawa,
Canada

You can create your own xml structure, so
you can represent directories and subdirectories in many ways.

lik this

<dir>
<dir name="directory 1">
</dir>
<dir name="dir2">
<dir name="subdir"/>
</dir>
</dir>
or like this:

<dir name="/directory1"/>
<dir name="/dir2"/>
<dir name="/dir2/subdir"

There are many ways.

True, but hard-naming subdir or directory{1|2.. .} is a case of premature
binding. I think the nesting of directory as originally suggested is
probably fine for this purpose.

///Peter


I dont know what you mean, the names directory1, or subdir are just
examples... the attribute name stands for the name of that directory.
Nov 23 '05 #4
In article <dl**********@t heodyn.ncf.ca>,
James Owens <ad***@FreeNet. Carleton.CA> wrote:
To represent directories and subidrectories, is it advisable to nest the
same element:

<directory>
<directory>
<directory>


There is no reason to avoid nesting elements with the same name if
that reflects the structure you want to represent, which it does in
this case.

-- Richard
Nov 23 '05 #5
Tjerk Wolterink wrote:
<dir name="/directory1"/>
<dir name="/dir2"/>
<dir name="/dir2/subdir"

There are many ways.

True, but hard-naming subdir or directory{1|2.. .} is a case of
premature binding. I think the nesting of directory as originally
suggested is probably fine for this purpose.

///Peter


I dont know what you mean, the names directory1, or subdir are just
examples... the attribute name stands for the name of that directory.


Sorry, you're quite right, and I didn't read carefully enough.
Serves me right for doing news too late :-)

///Peter

Nov 23 '05 #6

Thanks for the replies. I'll go with nesting if there's no problem with
it. (For some reason, none of the books I've read so far have examples of
nested elements.)
--
"For it is only of the new one grows tired. Of the old one never tires."
-- Kierkegaard, _Repetition_

James Owens, Ottawa, Canada
Nov 23 '05 #7
James Owens wrote:

I'm a relative newbie, interested in storing the information from several
server directories and subdirectories in XML so that I can present it
selectively using XSL (all files updated today or last MOnday, files from
several drirectories in alphabetical order, things like that).

To represent directories and subidrectories, is it advisable to nest the
same element:

<directory>
<directory>
<directory>

or is there a better way?

--
"For it is only of the new one grows tired. Of the old one never tires."
-- Kierkegaard, _Repetition_

James Owens, Ottawa, Canada

You might like to look at the kind of xml that the Apache
Cocoon project produces. It is the nested variety that you
proposed, with most of its workload carried as
attributes.

In fact, I reckon you should download and install Apache and Cocoon,
even if you only use for it is as a environment for learning
xsl-t and xsl-fo. Its NOT easy, however.

see 'Guide to using Cocoon for Directory Listings'
----------------------------------------------
at the bottom of this message, which I hope contains
enough to get you going.
You wrote of
'storing the information from several
server directories and subdirectories in XML so that I can present it
selectively'

There is no real need to __store__ it as xml. The
Cocoon system will recalculate it on-the-fly, and feed
it to the xsl that you write.

Finally, it will spit it out using (if required) a non-xml
format, but you may prefer to skip this step for now, and
produce xhtml as the final product.

All you have to do, once the system is set up, is type a url of a
particular 'pattern' into your browser. Although this may look
like a typical hierarchical file-path, it doesn't have to resemble
your actual file system at all.

The crucial thing about this (for a 'relative newbie' ) is that
once you have a bare-bones Cocoon pipeline working that starts with
the supplied 'Directory Generator', you can spend 100% of your
time playing around with the xsl stage, which I guess is what you
want.
The 'Cocoon' component you need is called the
'DirectoryGener ator' and it produces (using
a namespace prefix of 'dir:' ) something like:

<?xml version="1.0" encoding="utf-8" ?>

<dir:director y
name="cocoon"
lastModified="1 032027000636"
date="14/09/02 19:10"
xmlns:dir = "http://apache.org/cocoon/directory/2.0" >

<dir:director y
name="mount"
lastModified="1 031537875786"
date="09/09/02">

<dir:file
name="Hi.txt"
lastModified="1 031537875786"
date="09/09/02"
size="2245" />
</dir:directory>
</dir:directory>
<--! ************** variations follow ************* -->

To use it, you can specify some parameters, in the 'sitemap'
which is another xml file.

<!-- defaults to 1, which is the depth to which
recursion into the subdirectories will happen) -->
<map:paramete r name="depth" value="5" />
<map:paramete r name="dateForma t" value="dd-MMM-yyyy hh:mm:ss />

<!-- leave the next parameter out (which is simplest for a beginner)
to get the directory tree starting at the current folder
The directory from which the generator was called always
gets an extra attribute
requested="true "

-->
<map:paramete r name="root" value="cocoon" />
<!-- the next parameter is a regular expression which tells
the generator which file and folder names to include -->
<map:paramete r name="include" value=".*" />
<map:paramete r name="exclude" value="\.bak$" />
<--! ************** variations ( of
the DirectoryGenera tor ) follow ************* -->
Cocoon also has some specialist directory Generators.

A. ImageDirectoryG enerator
--------------------------

..... selects JPEG and GIF files and adds attributes
for the width and height of each image
B. MP3DirectoryGen erator
------------------------

..... selects mp3 files and adds lost of attributes such as
frequebcy, bitrate, mode, variablerate, title, artist, album,
comment, Etc which it extracts from the mp3 embedded data.


By the way, if you _do_ want to roll your own xml for
directory structure, the task is given as an example sub-task in
the O'Reiley book 'Python and XML', where the main task is to
build a file of 'thumbnails'. The python script index.py
does the work; make sure you don't leave it in the
state where it follows symbolic links as well as true
file-hierarchy children, or you might well hit an
infinite loop. This caution applies to other programmes you
might write as well.
It would be easy to modify this script to extract information
sometimes embedded (like the mp3 example above) in certain
pixel graphics formats. Last time I looked, the Cocoon version
didn't do that, I don't know why not, and only dealt with
jpegs and gifs.


'Guide to using Cocoon for Directory Listings'
---------------------------------------------

There is a sample 'DirectoryLisin gs' project in
path.to.cocoon-2.1.5/webapp

As an experiment ( but NOT unless your server is
secure from intruders ) let us do Direcory Listings
of part of your system, starting at

path/to/where/to/start

Go into ..webapp/DirectoryListin gs, and open
'sitemap.xmap' in your editor.

Actually, if you are cautious, perhaps you should first
save a copy to a version control system or other backup, in
case you mess everything up.
copy (twice) the two nested elements
<map:pipeline >
<map:match pattern="**.xml " >

blah blah blah

</map:match>
</map:pipeline>
Edit the copies as follows:

<map:pipeline >
<map:match pattern="**.Hom exml">
<map:generate type="directory " src="/path/to/where/to/start/{1}" >
<map:paramete r name="depth" value="7" />
<map:paramete r name="reverse" value="true" />
<map:paramete r name="root" value="path/to/where/to/start" />
</map:generate>
<map:transfor m src="style/xmllist.xsl" />
<map:serializ e type="xml"/>
</map:match>
</map:pipeline>

<map:pipeline >
<map:match pattern="**.Ver sionOne">
<map:generate type="directory " src="/path/to/where/to/start/{1}" >
<map:paramete r name="depth" value="7" />
<map:paramete r name="reverse" value="true" />
<map:paramete r name="root" value="path/to/where/to/start" />
</map:generate>
<map:transfor m src="style/list2VersionOne .xsl" />
<map:serializ e type="xhtml"/>
</map:match>
</map:pipeline>
Make sure these two new items are safely inside the
<map:pipeline s> ... </map:pipelines> part of the file.

*************** ******* First Test *************** *******

Now, in your browser (eg Mozilla - it needs to be one that will
display xml without fuss:

http:8080/DirectoryListin gs/One/Two.Homexml

should produce the xml version of directory
path/to/where/to/start/One/Two/

************* Write your own xsl, and second test **********

When you have written suitable xsl to transform this to xhtml, and
saved it as
..cocoon-2.1.5/webapp/DirectoryListin gs/style/list2VersionOne .xsl

Your browser should display the xhtml when you type the url

http://localhost;8888/DirectoryListi...Two/VersionOne
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++++++++++++ ++++

Now you can play with the xsl.

Add an entry to the pipeline, with its own 'pattern' and one or more
<xsl:transfor m> elements similar to those above, where the 'src'
attribute matches the filename of your xsl file in the 'style'
subdirectory of the DirectoryListin gs Project.

Note that you can daisy-chain more than one xsl transformation in
the sitemap, which sometimes makes for a cleaner design.

*************** *************** *************** *************** *******


Nov 23 '05 #8
Peter Flynn wrote:
Tjerk Wolterink wrote:

James Owens wrote:
I'm a relative newbie, interested in storing the information from
several server directories and subdirectories in XML so that I can
present it selectively using XSL (all files updated today or last
MOnday, files from several drirectories in alphabetical order, things
like that).

To represent directories and subidrectories, is it advisable to nest
the same element:

<directory>
<directory>
<directory>

or is there a better way?

--
"For it is only of the new one grows tired. Of the old one never
tires." -- Kierkegaard, _Repetition_

James Owens, Ottawa,
Canada

You can create your own xml structure, so
you can represent directories and subdirectories in many ways.

lik this

<dir>
<dir name="directory 1">
</dir>
<dir name="dir2">
<dir name="subdir"/>
</dir>
</dir>
or like this:

<dir name="/directory1"/>
<dir name="/dir2"/>
<dir name="/dir2/subdir"

There are many ways.

True, but hard-naming subdir or directory{1|2.. .} is a case of premature
binding. I think the nesting of directory as originally suggested is
probably fine for this purpose.

///Peter


I dont know what you mean, the names directory1, or subdir are just
examples... the attribute name stands for the name of that directory.
Nov 24 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
5317
by: FISH | last post by:
Ever have one of those days when you're not sure if it's you who's gone mad, or the rest of the world? I have an Open Source project on SourceForge for communication with YSMG - Yahoo's IM protocol. I keep the project source in three directories, based upon the code's function: one for the network API code itself, one for the support APIs...
2
2332
by: Jignesh | last post by:
Can someone please tell me how to "import" a directory structure into a project in Microsoft Visual C++ .NET 2003. I have an extremeley complex directory structure consisting of thousands of files and hundreds of subdirectories. I want to be able to view all of these inside of my project in the same directory structure format. I don't want...
1
5083
by: soni29 | last post by:
when creating a project with namespace like: wrox.csharp.basics.overflowtest is it good practice to have the directory structure like that also: c:\wrox\csharp\basics\overflowtext.cs Also if it is then is there a way to make visual studio set it up for me as i'm creating the cs files? or do i have to first create the directory structures...
4
3696
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have Directory.GetFileSystemEntries(path), but I would like to know how to put this together, knowing which entry is a Subdirectory and which entry is a...
6
4548
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application restarts and all active sessions are terminated. This error is also described in detail here:...
10
2064
by: Alan Searle | last post by:
I would like to scan a directory structure into XML to offer navigation functionality in HTML / XSL pages. My questions are: 1. Which is the best structure to store variable depth heirarchies in XML (i.e. different branches of the directory structure will have different 'depths'). 2. I am currently using VBA to prepare the pages and...
1
2123
by: Greg | last post by:
Hi, I need to implement a table in XBRL. Let's assume I have 2 simple tables to define: TABLE 1 col1 col2 row1 A C row2 B D TABLE 2
6
4636
by: penny | last post by:
In this assignment we shall look at a possible representation of rational numbers in java using objects. The java language represents rational numbers using the same representation used for other real numbers. This is the floating-point representation. However as we may all know, floating-point numbers are quite inaccurate. This means that ½ might...
8
6379
by: theCancerus | last post by:
Hi All, I am not sure if this is the right place to ask this question but i am very sure you may have faced this problem, i have already found some post related to this but not the answer i am looking for. My problem is that i have to upload images and store them. I am using filesystem for that. setup is something like this, their will...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.