1 default
namespace this
= "http://thaiopensource.com/ns/locating-rules/1.0"
6 locatingRules
= element locatingRules
{ common, rule*
}
17 # | typeIdProcessingInstruction
23 ## Group of rules. Useful with xml:base.
24 group
= element group
{ common, rule*
}
29 attribute rules
{ xsd:anyURI
}
33 element applyFollowingRules
{
41 |
"typeIdProcessingInstruction"
47 ## Matches if the prefix and/or local name of document element
48 ## match the values of the prefix and localName attributes.
49 element documentElement
{
55 ## If there's no prefix attribute, then only the local name must match.
56 ## If there's no local name attribute, then only the prefix must match.
57 nameAtts
= (prefixAtt, localNameAtt?) | localNameAtt
59 ## prefix="" matches if the document element has no prefix.
60 prefixAtt
= attribute prefix
{ (xsd:NCName -
"xmlns") |
"" }
61 localNameAtt
= attribute localName
{ xsd:NCName -
"xmlns" }
64 ## Matches if the document has a DOCTYPE declaration with a public
65 ## identifier that, after normalization, matches the value of the
66 ## publicId attribute.
67 element doctypePublicId
{
69 attribute publicId
{ publicIdValue
},
75 ## Newline and tab are excluded, because pattern applies to
76 ## the post-normalization value.
77 pattern
= "[\-'()+,./:=?;!*#@$_%a-zA-Z0-9 ]*"
80 # This is separate from documentElement so it can be distinguished
81 # by applyFollowingRules.
83 ## Matches if the document element has a namespace URI equal to the value
84 ## of the ns attribute. A document element with no namespace matches if
85 ## the value of the ns attribute is the empty string.
88 attribute ns
{ xsd:string
},
93 ## Matches based on the URI of the document.
96 (resourceAtt | patternAtt),
100 ## Matches if it can be determined that the document resource is
101 ## the same resource as that identified by the value of the resource
102 ## attribute. In determining this, the implementation should apply
103 ## the semantics of the URI scheme used by the URI.
104 resourceAtt
= attribute resource
{ xsd:anyURI
}
106 ## Matches if the document's URI matches the pattern specified
107 ## by the pattern attribute. A * in the path component matches
108 ## zero or more characters other than / (after resolving escapes).
109 ## If the pattern is a relative URI, it means that there must
110 ## be some URI such that when the pattern is resolved relative
111 ## to that URI, it matches the document's URI. Thus an empty
112 ## pattern will always match.
113 patternAtt
= attribute pattern
{ uriPattern
}
115 ## A pattern for a URI. Same syntax as a URI, except that a * in
116 ## the path component has a special meaning.
117 uriPattern
= xsd:anyURI
120 ## Generates a URI for the related resource by transforming
121 ## the URI of the document. Matches if the transformation
122 ## yields a valid URI that identifies an existing resource.
123 element transformURI
{
125 ## Semantics are the same as the pattern attribute of the uri element.
126 attribute fromPattern
{ uriPattern
},
127 ## The result of the transformation is produced from the toPattern
128 ## by replacing each * by the string that matched the corresponding
129 ## * in the toPattern. The toPattern is appended to the initial
130 ## part of the document's URI that was not explicitly matched
132 attribute toPattern
{ uriPattern
}
142 ## A document can be mapped onto a URI either indirectly via a typeId
144 targetAtt
= uriAtt | typeIdAtt
146 ## Specifies the URI of the related resource.
147 ## xml:base is used if it's relative.
148 uriAtt
= attribute uri
{ xsd:anyURI
}
150 ## Specifies an identifier of the type of document. typeId and
151 ## typeIdBase rules will be used to map this to a URI.
152 typeIdAtt
= attribute typeId
{ typeIdValue
}
154 ## A type identifier can be anything convenient (e.g. a public identifier,
155 ## a URL or just a string with no formal structure). Whitespace is
156 ## normalized like a public identifier before comparing type identifiers
158 typeIdValue
= xsd:token
160 typeIdProcessingInstruction
=
161 ## Matches if there's a processing instruction in the prolog
162 ## before any DOCTYPE declaration whose target is the value of
163 ## the target attribute. The value of the processing instruction
164 ## is interpreted as a typeId, which will be mapped to a
166 element typeIdProcessingInstruction
{
168 attribute target
{ xsd:NCName
}
172 ## Maps a typeId onto a URI.
175 attribute id
{ typeIdValue
},
180 ## Used to map a typeId onto a URI. First, any URI reserved characters
181 ## are URI encoded. If the append attribute is specified, it is appended.
182 ## This is then treated as a URI. If relative, it is resolved using
183 ## the applicable base URI as usual. If the resulting URI identifies
184 ## an existing resource, then the typeId is mapped to this resource.
185 ## This is intended to be useful with file URIs.
188 attribute append
{ xsd:string
}?
193 attribute *
{ text
}*, (text|anyElement)*
196 anyElement
= element *
{ attribute *
{ text
}*, (text|anyElement)*
}
199 # attribute xml:base { xsd:anyURI }?,
200 attribute * - (xml:base|this:*|local:*)
{ text
}*