[lxml-dev] schema validation - what would be valid at this point?

John Lovell jlovell at esd189.org
Mon Jun 30 22:02:34 CEST 2008


So with schema snippets that look like this, what would it give you as
valid input options?

<xs:attribute name="RefId" use="required" type="sif:RefIdType" />

  <xs:simpleType name="RefIdType">
    <xs:restriction base="sif:GUIDType" />
  </xs:simpleType>

  <xs:simpleType name="GUIDType">
    <xs:restriction>
      <xs:simpleType>
        <xs:restriction base="xs:token">
          <xs:pattern value="[0-9A-F]{32}"
xmlns:xs="http://www.w3.org/2001/XMLSchema" />
        </xs:restriction>
      </xs:simpleType>
    </xs:restriction>
  </xs:simpleType>

John W. Lovell
Web Applications Engineer
Northwest Educational Service District
1601 R Avenue
Anacortes, WA 98221
(360) 299-4086
jlovell at nwesd.org
 
www.nwesd.org
Together We Can ... 

-----Original Message-----
From: Terry Brown [mailto:tbrown at nrri.umn.edu] 
Sent: Monday, June 30, 2008 12:23 PM
To: John Lovell
Subject: Re: [lxml-dev] schema validation - what would be valid at this
point?

On Mon, 30 Jun 2008 11:49:50 -0700
"John Lovell" <jlovell at esd189.org> wrote:

> Can you give an example of what that might look like?

What I'd really like to have is the functionality of Emac's nxml-mode
via a Python API.  That mode parses the text up to the insert point, and
can then tell you what elements would be valid there, according to any
RELAX-NX schema you specify.

So really I guess it makes more sense to be able to get the answer at
parse time, rather than when the tree's complete.

If, so far, the parser has seen "<html><head>" the answer to the
question "what's valid at this point?" would be "base, isindex, link,
meta, script, style, title".  I don't know if the
libxml2 schema API will answer that question, if not then it's more a
libxml2 feature request (initally :) rather than an lxml thing.  Just
using HTML as an example, you could answer in terms of any user supplied
schema.

Sorry my initial description was confused because I was thinking about
already complete and valid trees to which you might add something, it
would be nice to handle that case too, but it seems to make more sense
to approach it from the incomplete, half parsed :-) tree point of view
first.

Cheers -Terry
 

> John W. Lovell
> Web Applications Engineer
> Northwest Educational Service District
> 1601 R Avenue
> Anacortes, WA 98221
> (360) 299-4086
> jlovell at nwesd.org
>  
> www.nwesd.org
> Together We Can ...
> 
> 
> -----Original Message-----
> From: lxml-dev-bounces at codespeak.net
> [mailto:lxml-dev-bounces at codespeak.net] On Behalf Of Terry Brown
> Sent: Monday, June 30, 2008 11:20 AM
> To: lxml-dev at codespeak.net
> Subject: [lxml-dev] schema validation - what would be valid at this 
> point?
> 
> Hi all,
> 
> First thanks for lxml - it's great.
> 
> If this is the wrong place for feature requests please point me 
> elsewhere...
> 
> A feature that would be very useful for a number of applications, 
> particularly editors: the ability to ask "what attributes / elements 
> would be valid at this point?" where I guess a point would be 
> identified by an XPath or perhaps an Element object.
> 
> I don't know if any of the libxml2 schema APIs expose this, if they 
> don't, that's probably where the change needs to be made first, but if

> they do it would be great if lxml passed it on to python.
> 
> Thanks,
> 
> Terry
> _______________________________________________
> lxml-dev mailing list
> lxml-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/lxml-dev
> 



-----------------------------------------------------------------------
Terry Brown               Natural Resources Research Institute
Research Associate        5013 Miller Trunk Highway
tbrown at nrri.umn.edu       University of Minnesota, Duluth
Ph. 218 720 4345          Duluth, Minnesota 55811
Fax 218 720 4328          http://beaver.nrri.umn.edu/~tbrown/


More information about the lxml-dev mailing list