Subject: Re: [xsl] Unparsed-text-available returns true for XML files, so how do I distinguish XML files? From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Sun, 3 Jan 2010 18:47:10 +0000 |
2010/1/3 Syd Bauman <Syd_Bauman@xxxxxxxxx>: >> 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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Unparsed-text-available r, Syd Bauman | Thread | Re: [xsl] Unparsed-text-available r, Syd Bauman |
Re: [xsl] Unparsed-text-available r, Syd Bauman | Date | RE: [xsl] Unparsed-text-available r, Michael Kay |
Month |