xsl-list
[Top] [All Lists]

Re: [xsl] Anyone have XSLT that generates XML showing a Windows folder structure?

2020-05-13 14:55:50
Hi Roger,

There are too-many characters that are allowed in a directory-name that
will break the syntax for an XML element name:

seems like any character except:  (0 to 31)!codepoints-to-string(.),  \, /
, ?,:, *, ", <, >, |

So you can have commas, whitespace (consecutive spaces), %, ;, +, &, etc.
For reference see for example this:
https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file    ,

Therefore, a safer way to represent a directory structure would be to make
the file and directory names values, not names.

Even in this case, the & (ampersand) character must be watched for and
escaped properly.

Also, given an XML file in this format, that is believed to represent a
directory, may actually not represent a real windows filesystem directory,
as there are reserved names that have special meaning and are not allowed
to be used:

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9,
LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these
names followed immediately by an extension; for example, NUL.txt

One more thing: you might have a problem if the length of a full
filepath exceeds 250.

HTH, :)

Cheers,
Dimitre

On Wed, May 13, 2020 at 5:52 AM Costello, Roger L. 
costello(_at_)mitre(_dot_)org <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hi Folks,

Do you have XSLT code that does this: Given a root folder, show all the
subfolders and files within it, repeat for each subfolder.

Example, for this folder structure:

root
    persons
        local
            JohnDoe.xml
            MarySmith.xml
        remote
            BillAnderson.xml

the XSLT code outputs this XML:

<root>
     <persons>
          <local>
              <john>JoeDoe.xml</john>
              <mary>MarySmith.xml</mary>
        </local>
        <remote>
             <bill>BillAnderson.xml</bill>
       </remote>
    </persons>
</root>

If someone has already done this, would you mind sharing it, please?

/Roger


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>