[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
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|