Re: validating xml with schema and libxml - expression could not be compiled
by Martin J. Evans other posts by this author
Jul 14 2006 5:07AM messages near this date
view in the new Beta List Site
Re: validating xml with schema and libxml - expression could not be compiled
|
Out of Office
& XSLT On 14-Jul-2006 Petr Pajas wrote:
> Hi,
>
> Check if xmllint validates your document. If not and you are sure your schema
> is correct, then the problem probably lies in libxml2 and you should report
> there (see http://xmlsoft.org/bugs.html).
Petr,
Thanks. xmllint did not accept the pattern either.
I've discovered that XML Schema only uses a subset of XPath and that text() is
not included in that subset. However, just specifying the element itself refers
to the content so the following works:
<xs:key name="entrantcontent">
<xs:selector xpath="./entrants/entrant"/>
<xs:field xpath="."/>
</xs:key>
BTW, thanx to the XML Schema group for a very fast answer helping me discover
this.
Martin
--
Martin J. Evans
Easysoft Ltd, UK
http://www.easysoft.com
> -- Petr
>
> On Thursday 13 July 2006 14:52, Martin J. Evans wrote:
> > Hi,
> >
> > I am attempting to validate an XML file with a schema using XML::LibXML.
> >
> > A portion of the XML looks like this:
> >
> > <event name="name" type="type" timestamp="2006-05-19T17:25:00">
> > <entrants>
> > <entrant external_id="1" status_id="1">fred</entrant>
> > <entrant external_id="2" status_id="1">fred2</entrant>
> > <entrant external_id="3" status_id="1">fred3</entrant>
> > <entrant external_id="4" status_id="1">fred4</entrant>
> > <entrant external_id="5" status_id="1">fred5</entrant>
> > </entrants>
> > </event>
> >
> > and all the entrant element text should be unique so the xsd says:
> >
> > <xs:key name="entrantcontent">
> > <xs:selector xpath="./entrants/entrant"/>
> > <xs:field xpath="text()"/>
> > </xs:key>
> >
> > but I cannot get XML::LibXML to accept the field xpath expression as it
> > always reports:
> >
> > Element '{http://www.w3.org/2001/XMLSchema}field', attribute 'xpath': The
> > XPath expression 'text()' could not be compiled.
> >
> > As each entrant has attributes and content I only wanted to pick the
> > content as having to be unique. Is my xpath expression wrong or perhaps
> > text() is not supported?
> >
> > Martin
> > --
> > Martin J. Evans
> > Easysoft Ltd, UK
> > http://www.easysoft.com
> >
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Martin J. Evans
Petr Pajas
Martin J. Evans
|