473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Directory Scanning

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 export to XML and
was wondering if there are any tools around which will save me the
coding 'leg-work'? (i.e. directly transfer the directory structures
into XML)

Any tips on either of these points would be a great help to me.

Many thanks,
Alan Searle.
Feb 18 '06 #1
10 2045
Alan,

to store dirs i use normaly the HTML-like syntax like

<ul>
<li>usr
<ul>
<li>local</li>
</ul>
</li>
</ul>

that has 2 advantages:

1) For HTML-Output i can use a simple xsl:copy-of ...
2) For creating and manipulation you can use recursivity, that makes
your code thin you just need one method that calls itself, if there are
children.

Hope that helps.

Cheers,
Dominik

Feb 18 '06 #2
fedro wrote:
Alan,

to store dirs i use normaly the HTML-like syntax like

<ul>
<li>usr
<ul>
<li>local</li>
</ul>
</li>
</ul>

that has 2 advantages:

1) For HTML-Output i can use a simple xsl:copy-of ...
2) For creating and manipulation you can use recursivity, that makes
your code thin you just need one method that calls itself, if there are
children.

Hope that helps.

Cheers,
Dominik


That is really a bad xml format for a directory structure.
The tags should say something about the data.

I would like this better:

<file name="dir1">
<file name="dir2">
<file name="file.xml"/>
</file>
<file name="config.txt">
</file>

You can view directories as files too.
One problem: symbolic links can result in endless recursion.

Feb 19 '06 #3
On Sun, 19 Feb 2006 18:49:05 +0100, Tjerk Wolterink
<tj***@wolterinkwebdesign.com> wrote:
You can view directories as files too.


Not a good idea in XML though. The idea that "directories are a funny
sort of file" is an artefact of some _implementations_ of file systems.
As far as data modelling goes it's not the sort of coincidental factor
that should be preserved into a more abstract representation.

For one thing (and relevant to XML / DTD design) what should the content
model be for the children of this "file or directory" node ? Does it
have child nodes (as a directory does) or not (as a file does) ?
"Borrowing" HTML elements is bad software design too because it's
confusing the fact that these are entirely separate elements because
they're taken from separate namespaces. Relying on copy-of working and
giving the elements matching local-name() properties is piss-poor
software engineering. Look up a textbook from back when such things were
last taught (1980s ?) and lookup the concept of "coupling".
Feb 19 '06 #4
> That is really a bad xml format for a directory structure.

No it isn't!

What is a directory at least? It is an unordered list of items wich
contains other unorderd lists of items. And that is exactly, what my
tag <ul> with * children of <li> (=ListIitems) stands for.

You can extend the <li> tags with more information, i.e.
modifiedDate="20060219184905", extension="pdf" tags an so on.

With the extension-Attribute it is realy simple to create Icons for the
list by CSS.

And, Tjerk, with your solution it is not very easy (and so not very
fast ..) to know if a children is a subdirectory or a file.

Follow the KISS principle.

Cheers,
Dominik

Feb 20 '06 #5
Hi everyone,

I have been fishing around on other forums and have found a really easy
(DOS command) way of 'grabbing' directory trees ...

dir c:\mydir /a:d /b /s>dirs.txt

It was a big relief to find that.

And regarding directory trees, I think I will first try an adapted
version of Fedro's HTML suggestion. Mine would include files and
properties and would look something like the following ...

<root>
<startdir>mylocaldir1
<dir>dir1
<file>file1
<creationdate>20060211</creationdate>
<owner>John Smith</owner>
</file>
<file>Another file
</file>
</dir>
<dir>Another directory
<file>Yet another file
</file>
</dir>
</startdir>
</root>

I would store complete directory paths which might get a bit long but at
this stage, simplicity is probably the best. I'll then see how my
navigation mechanisms pan out and may need to review the structure.
Indeed, I am even pondering storing a parallel XML file in the more
'pure' (fragmented) format, containing a link ID that would enable
navigation to be based on the 'pure' XML and then information retrieval
using the HTML style structure.

Thanks for your tips and comments as these have really helped to get me
thinking about the problem.

And I hope that my feedback is useful for you?

All the best,
Alan Searle.

Andy Dingley schrieb:
On Sun, 19 Feb 2006 18:49:05 +0100, Tjerk Wolterink
<tj***@wolterinkwebdesign.com> wrote:

You can view directories as files too.

Not a good idea in XML though. The idea that "directories are a funny
sort of file" is an artefact of some _implementations_ of file systems.
As far as data modelling goes it's not the sort of coincidental factor
that should be preserved into a more abstract representation.

For one thing (and relevant to XML / DTD design) what should the content
model be for the children of this "file or directory" node ? Does it
have child nodes (as a directory does) or not (as a file does) ?
"Borrowing" HTML elements is bad software design too because it's
confusing the fact that these are entirely separate elements because
they're taken from separate namespaces. Relying on copy-of working and
giving the elements matching local-name() properties is piss-poor
software engineering. Look up a textbook from back when such things were
last taught (1980s ?) and lookup the concept of "coupling".

Feb 20 '06 #6
Alan Searle wrote:
<file>file1
<creationdate>20060211</creationdate>


Put the filename into an attribute, not the element's content. You have
child elements in there too (unavoidably so for directories) and
processing mixed content is always a real pain.

Feb 20 '06 #7
OK :-)

Thanks very much for the tip.

Cheers,
Alan.

Andy Dingley <di*****@codesmiths.com> schrieb:
Alan Searle wrote:

<file>file1
<creationdate>20060211</creationdate>

Put the filename into an attribute, not the element's content. You have
child elements in there too (unavoidably so for directories) and
processing mixed content is always a real pain.

Feb 20 '06 #8
Alan Searle wrote:
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').
XML structure is a tree. Directory structure is a tree (barring
additional links/symlinks). Map the latter to the former, however makes
most stense for your application.
coding 'leg-work'? (i.e. directly transfer the directory structures
into XML)


Find a code example of walking a directory tree. Alter it to output XML.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Feb 22 '06 #9
Hi Joe,
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').

XML structure is a tree. Directory structure is a tree (barring
additional links/symlinks). Map the latter to the former, however makes
most stense for your application.


OK. But other contributers have said I should only store data in the
very 'tips' of the XML tree (i.e. not in intermediate branches). This
seems to rule out handling directory structures in the body of the tree.

Or should I use the directory names as 'tags' rather than data items in
the tree?
coding 'leg-work'? (i.e. directly transfer the directory structures
into XML)

Find a code example of walking a directory tree. Alter it to output XML.


Yes, I have found some code to handle this :-)

Thanks very much for your tips.

Regards,
Alan Searle.
Mar 2 '06 #10
Alan Searle wrote:
OK. But other contributers have said I should only store data in the
very 'tips' of the XML tree (i.e. not in intermediate branches).


Depends on what you're trying to do, and what you mean by "tip". I'd
suggest this is a perfect case for an attribute -- use something like
<directory name="whatever"> elements to build your directory tree
representation. (It could of course be done with a <name> child of the
<directory> element, but that wouldn't be as natural a way to express it
or manipulate it.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 6 '06 #11

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

Similar topics

2
by: Dean | last post by:
Hi I've got a question relating to using Javascript on an Intranet. I have a directory with a list of files in the format week36.xls, week37.xls and I want to write a script that will scan...
39
by: Joe Laughlin | last post by:
If I have a character array with "/some/file/directory/file_name", are there any functions / libraries that I could use to separate the directory ("some/file/directory") from the file name...
4
by: Nazgob | last post by:
Hello! I'm looking for cross-platform directory scanning library working with ansi C. I need to use in in GNU Linux and Windows. I need to do simple directory and files opertionson both OS, can...
2
by: Alan Searle | last post by:
I would like to 'grab' certain directory trees and then store them in a table. At the moment, I writing my own VBA to do this but I cannot help thinking that there must already be something...
5
by: johnwayne83 | last post by:
This is my first semester in c++ and i took java last semester. I need some help and i really cant find any information that has helped me or to point me in the right direction. I am using...
1
kirubagari
by: kirubagari | last post by:
For i = 49 To mfilesize Step 6 rich1.SelStart = Len(rich1.Text) rich1.SelText = "Before : " & HexByte2Char(arrByte(i)) & _ " " & HexByte2Char(arrByte(i + 1)) & " " _ &...
1
by: ahammad | last post by:
Hello, I would like to scan a certain directory for XML files. Then I want to take in every XML file, read it, and stores the contents as a string in an array. For example, if the directory has...
7
by: paul86 | last post by:
Hi all, I have a vb question that i'm hoping I can get some help with. I have a directory of excel files (probably about 1000) of them. They are quote sheets for the company I work for, and they...
8
by: aki | last post by:
Hi All, I describe the problem as below. A directory( path known) , contains 0 to any number of files . The file names are with following structure : ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.