Re: [phplib] why not XML/LDAP From: fred <email protected>
Date: 08/07/01

On Mon, Aug 06, 2001 at 09:32:51PM -0000, Kristian Koehntopp wrote:
> Has anyone here on this already looked into XML Schema? I have
> had only a very cursory glance, and I'd like to see some kind of
> executive summary and some comparison "DTD vs. XML Schema vs.
> SQL table definitions with constraints and triggers".

I haven't found such an analysis, but I would suggest Elliotte Rusty
Harold's chapter on XML Schemas from his "XML Bible, 2nd Ed." book:
<http://www.ibiblio.org/xml/books/bible2/chapters/ch24.html>. That
chapter teaches XML Schema basics using an extended example. I found
it to be a great resource, but it's lengthy and not at all an
executive summary.

> Also, which tools already support XML Schema?

The Apache Xerces parser (Java, version 1.4.2) is comprehensive. They
admit to only a small number of incomplete XML Schema features.
<http://xml.apache.org/xerces-j/schema.html>

> _But_ I would not think of querying to XML to perform a keyword
> search on that. Instead I wrote an XSLT file that converts this
> structure into a CSV datafile that can be imported into MySQL
> and I query those SQL tables with keyword searches ...

Cool. That's a technique I'll try someday.

> Also, I am not using docbook but some custom format because I want
> structure, not layout, and because I want specialized custom
> internal and external references. Using a third XSLT file, I could
> create docbook from by FAQ format at any time.

Yes, DocBook is so generic and _large_, and I also tend to write my
own custom mini-DTD for my structured documentation.

But I often find that I want to employ some XHTML-style formatting in
the midst of the application/domain-oriented semantic markup.
Harold's book (URL above) presents a nice technique for defining
document types with both custom and XHTML markup. My take on his
approach is to add a section like this at the top of the DTD:

    <!ENTITY % myinline "filename | function">
    <!ENTITY % phrase "em | strong | dfn | code | q | sub | sup |
                samp | kbd | var | cite | abbr | acronym | %myinline;">
    <!ENTITY % xhtml PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                "xhtml1-strict.dtd">
    %xhtml;

So I've mixed in my own 'filename' and 'function' elements into the
XHTML 'phrase' parameter entity (at the cost of depending on the base
definition).

Similarly, I connect my application's block- and inline-level elements
with XHTML:

    <!ELEMENT explanation %Flow;>
    <!ELEMENT filename %Inline;>

where the XHTML DTD defines the 'Flow' and 'Inline' entities
(including the above 'phrase' entity among the choices).

To process the corresponding documents I add a template like this at
the bottom of the stylesheet:

    <xsl:template match="*|@*">
      <xsl:copy>
        <xsl:apply-templates select="node()|@*" />
      </xsl:copy>
    </xsl:template>
        
This overrides the default element and attribute templates so that
elements that aren't matched by another template are copied over as
is. I don't write templates for any of the XHTML elements, so they're
simply copied. Templates for any custom (non-XHTML) elements _are_
applied in the course of running apply-templates over the XHTML
element's descendents.

(OK, nobody asked, but I just had to share this approach that's
working very well for me.)

-- 
Fred Yankowski           fred <email protected>      tel: +1.630.879.1312
Principal Consultant     www.OntoSys.com       fax: +1.630.879.1370
OntoSys, Inc             38W242 Deerpath Rd, Batavia, IL 60510, USA

-- Abbestellen mit Mail an: phplib-unsubscribe <email protected> Kommandoliste mit Mail an: phplib-help <email protected>