xsl-list
[Top] [All Lists]

Re: [xsl] Unparsed-text-available returns true for XML files, so how do I distinguish XML files?

2010-01-03 13:47:34
2010/1/3 Syd Bauman <Syd_Bauman(_at_)brown(_dot_)edu>:
I use base-uri(/) and the sub-string functions to distinguish file
type.

While I suspect this answers the OP's question, as he referred to
file types in a way that indicates he is probably using the ultimate
part of the file name to indicate the file type, what base-uri()
really returns is the file's URI, and from that you can sub-string
its name and part of that is its extension.

But file extension and file type are *not* the same thing, although
many folks (and many pieces of software) keep them in synch by
convention. Just for starters, I have files with extensions of
 .xml
 .xhtml
 .rng
 .tei
 .odd
 .xsl
 .fo
 .xslt
 .dbk
that are all XML, and a few others that are only 1 automated step
away from being XML (.sgml, .rnc). Of course I can compare the
base-uri() to a list of recognizable extensions, but even this
has problems. There may be no extension, or it may be non-
standard, or it may be ambiguous.

So, is there a way to ask "is this XML" without considering the
file's name? I don't mind if it involves parsing the contents --
after all, if it's not well-formed, it's not XML.

That's pretty much exactly what fn:doc-available() does... it only
returns true if calling doc() with that uri would return a document
node.



-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--