[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Seek your suggestions on how to determine if an XMLSchema

  • From: "Liam R. E. Quin" <liam@fromoldbooks.org>
  • To: Roger L Costello <costello@mitre.org>, "xml-dev@l..." <xml-dev@l...>
  • Date: Fri, 05 Feb 2021 02:52:43 -0500

Re:  Seek your suggestions on how to determine if an XMLSchema
On Thu, 2021-02-04 at 20:36 +0000, Roger L Costello wrote:
> 
> I want to automate things: for each XPath-ish expression, determine
> if my XML Schema supports the structure denoted by the expression.

This is an interesting question, and has clear application for example
to XSLT match expressions.

One brute force way would be to construct a sample document for each
XPath expression, but apart from efficiency questions, i'm not sure
it's any easier than interpreting the schema.

We might say, given a path such as /a/b/c and an XML Schema S that
defines an "a" element of type T(a), can this contain an element of
name b, and if so is there such an element that can contain a child
called c.

This is somewhat complicated by substitution groups, but not
intractably, since schema validators exist.

Where the path is not rooted, it might be easier to work right to left,
as some XPath implementations do, so that for d/e/f you first look for
a definition of f and then ask if there's an e that can contain it, and
so on.

I can see adopting either of these approaches in XSLT.

It gets harder if there are additional rules, such as uniqueness
constraints or Schematron rules to satisfy. But i think i'd probably go
for the schema interpreter rather than the sample instance approach.

You could also write an optimizer. For example, if div can contain div,
then body/div/div/div/p can be rewritten as body/div/p for the purpose
of the test. That might help reduce the scale of the problem.

Liam

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.