You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jeff Turner <je...@apache.org> on 2003/03/07 13:25:44 UTC

XML type identification (Re: FAQ plugin available)

On Fri, Mar 07, 2003 at 10:46:15AM -0000, James Strachan wrote:
> From: "Jeff Turner" <je...@apache.org>
> > On Fri, Mar 07, 2003 at 08:33:16AM -0000, James Strachan wrote:
> > > I've put together a little plugin for generating xdoc documentation from
> a
> > > simple FAQ XML document.
> > ...
> > > A minor implementation note: I defaulted the file name to 'faq.fml' (fml
> =
> > > Faq Markup Language) to differentiate the extension from .xml or .html
> which
> > > might get picked up by other default goals in Maven.
> >
> > FYI, Forrest handles this problem by using Xerces' XNI to parse the first
> > bit of each XML file, and depending on certain characteristics (DOCTYPE,
> > xsi:schemaLocation, processing instruction, root element), assigning a
> > 'type':
> >
> >
> http://cvs.apache.org/viewcvs.cgi/xml-forrest/src/scratchpad/src/java/org/ap
> ache/forrest/components/sourcetype/SourceTypeAction.java?rev=HEAD&content-ty
> pe=text/vnd.viewcvs-markup
> >
> > I imagine the code could be wrapped in a Jelly tag if you want to go this
> > route.
> 
> Agreed - it might be nice to have some kind of similar mechanism.  I went
> for the simplest possible solution just to get things going :).
> 
> BTW I'm not a fan of DOCTYPEs since it means most tools can't parse your XML
> unless they know where the dtd actually is etc.

Ant now has pretty decent catalog support, as do many XML editors, and
tools like xmllint.

But yes, DTDs and DOCTYPEs are not long-term viable.  Sooner or later
someone will want XInclude support, and then you hit the namespace
problem.

> I like the use of DTDs to be optional by end users (who for example
> might have a DTD aware editor) but would prefer their use to be
> optional. Maybe using XSD might be less painful.

Probably.  What I'd most like is a simple PI:

<?meta doctype="urn:apache:faq"?>

Then the processor could use Relax NG or Schematron or whatever seems
best.

But then, perhaps the whole notion of "document types" need to be
rethought.  How about if the "unit of evolution" in XML were the element,
not the document type.  Each element would have a schema and stylesheet,
and be packaged with its own metadata:

<element id="programlisting">
  <description>
    Hold a block of code
  </description>
  <schema type="schematron" href="programlisting.sch"/>
  <category>inline</category>
  <converters>
    <convert to="xhtml" type="xslt" href="pl2xhtml.xsl"/>
    <convert to="docv11" type="xslt" href="pl2document.xsl"/>
    <convert to="xhtml" type="jsl" href="pl2xhtml.jsl"/>
  </converters>
</element>

Then one could add <programlisting lang="java"> to *any* XML file
(notably XHTML), and have it rendered as colourized Java code.

Just random thoughts..


--Jeff

> James
> -------
> http://radio.weblogs.com/0112098/
>