3 // RELAX NG Compact Syntax parser
6 // Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
8 // (C)2003 Atsushi Enomoto
10 // Copyright (c) 2004 Novell Inc.
11 // All rights reserved
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System.Collections;
37 using System.Collections.Specialized;
40 using Commons.Xml.Relaxng;
42 namespace Commons.Xml.Relaxng.Rnc
45 public class RncParser
47 public static RelaxngPattern ParseRnc (TextReader reader)
49 return ParseRnc (reader, new NameTable ());
52 public static RelaxngPattern ParseRnc (TextReader reader, XmlNameTable nameTable)
54 return new RncParser (nameTable).Parse (reader);
57 XmlNamespaceManager nsmgr;
58 XmlNamespaceManager dtnsmgr;
59 string defaultNamespace = String.Empty;
61 RncTokenizer tokenizer;
63 public RncParser (XmlNameTable nameTable)
65 nsmgr = new XmlNamespaceManager (nameTable);
66 dtnsmgr = new XmlNamespaceManager (nameTable);
67 ErrorOutput = System.IO.TextWriter.Null;
71 get { return tokenizer.Line; }
75 get { return tokenizer.Column; }
78 // note that this is different notion than that of xmlns.
79 public string DefaultNamespace {
80 get { return defaultNamespace; }
83 public RelaxngPattern Parse (TextReader source)
86 // debug = new yydebug.yyDebugSimple ();
87 tokenizer = new RncTokenizer (source);
88 return (RelaxngPattern) yyparse (tokenizer);
89 } catch (Exception ex) {
\r
90 throw new RelaxngException (String.Format ("Tokenizer error at line {0}, column {1}: {2}", Line, Column, ex.Message), ex);
\r
95 private void FillGrammarContent (IList source, IList starts, IList defines, IList divs, IList includes)
97 foreach (RelaxngElementBase elem in source) {
98 if (elem is RelaxngStart)
100 else if (elem is RelaxngDefine)
102 else if (elem is RelaxngDiv)
104 else if (elem is RelaxngInclude)
107 throw new InvalidOperationException ();
111 private XmlQualifiedName SplitQName (XmlNamespaceManager nsmgr, string name)
113 int colon = name.IndexOf (':');
115 return new XmlQualifiedName (name, String.Empty);
116 string local = name.Substring (colon + 1);
117 string prefix = name.Substring (0, colon);
118 return new XmlQualifiedName (local, nsmgr.LookupNamespace (nsmgr.NameTable.Get (prefix)));
121 private void FillElementDefaultNS (RelaxngNameClass nc)
123 RelaxngName name = nc as RelaxngName;
125 if (name.Namespace == null)
126 name.Namespace = this.DefaultNamespace;
129 RelaxngNameChoice choice = nc as RelaxngNameChoice;
130 if (choice != null) {
131 foreach (RelaxngNameClass c in choice.Children)
132 FillElementDefaultNS (c);
136 private void FillAttributeDefaultNS (RelaxngNameClass nc)
138 RelaxngName name = nc as RelaxngName;
140 if (name.Namespace == null)
141 name.Namespace = String.Empty;
144 RelaxngNameChoice choice = nc as RelaxngNameChoice;
145 if (choice != null) {
146 foreach (RelaxngNameClass c in choice.Children)
147 FillAttributeDefaultNS (c);
156 %token KeywordAttribute "attribute"
157 %token KeywordDefault //"default"
158 %token KeywordDatatypes "datatypes"
159 %token KeywordDiv "div"
160 %token KeywordElement "element"
161 %token KeywordEmpty "empty"
162 %token KeywordExternal "external"
163 %token KeywordGrammar "grammar"
164 %token KeywordInclude "include"
165 %token KeywordInherit "inherit"
166 %token KeywordList "list"
167 %token KeywordMixed "mixed"
168 %token KeywordNamespace //"namespace"
169 %token KeywordNotAllowed "notAllowed"
170 %token KeywordParent "parent"
171 %token KeywordStart "start"
172 %token KeywordString //"string"
173 %token KeywordText "text"
174 %token KeywordToken "left"
180 %token CloseCurly "}"
182 %token CloseParen ")"
183 %token OpenBracket "["
184 %token CloseBracket "]"
189 %token BackSlash "\\"
193 %token AndEquals "&="
194 %token TwoGreaters ">>"
196 %token LiteralSegment
197 %token NCNameButKeyword
201 /* These tokens are parsed by RncTokenizer, since whitespaces between
202 the particles are not allowed. */
212 TopLevel /* returns RelaxngPattern */
213 /* TODO: here Annotations is not specified in the spec!! */
214 : Annotations TopLevelAfterAnnotations
216 $$ = (RelaxngPattern) $2;
220 TopLevelAfterAnnotations /* returns RelaxngPattern */
221 /* TODO: here Annotations is not specified in the spec!! */
222 : Preamble TopLevelBody
224 $$ = (RelaxngPattern) $2;
228 Preamble /* returns null */
239 Decl /* returns null */
240 : KeywordNamespace NamespacePrefix Equal NamespaceURILiteral
243 string prefix = (string) $2;
244 string ns = (string) $4;
245 if (prefix == "local")
246 nsmgr.AddNamespace (String.Empty, ns);
248 nsmgr.AddNamespace (prefix, ns);
251 | KeywordDefault KeywordNamespace Equal NamespaceURILiteral
254 string ns = (string) $4;
255 defaultNamespace = ns;
258 | KeywordDefault KeywordNamespace NamespacePrefix Equal NamespaceURILiteral
261 string prefix = (string) $3;
262 string ns = (string) $5;
263 defaultNamespace = ns;
264 nsmgr.AddNamespace (prefix, ns);
267 | KeywordDatatypes DatatypePrefix Equal Literal
270 string prefix = (string) $2;
271 string ns = (string) $4;
272 dtnsmgr.AddNamespace (prefix, ns);
277 NamespacePrefix /* returns string */
278 : IdentifierOrKeyword
284 DatatypePrefix /* returns string */
285 : IdentifierOrKeyword
291 NamespaceURILiteral /* returns string */
302 TopLevelBody /* returns RelaxngPattern */
305 // TODO: Constraint: single element
306 // IList pl = (IList) $1;
307 // if (pl.Count != 1)
308 // throw new RelaxngException ("The number of the top level pattern must be exactly one.");
310 $$ = (RelaxngPattern) $1;
314 RelaxngGrammar g = new RelaxngGrammar ();
315 RelaxngGrammarContentList list = (RelaxngGrammarContentList) $1;
316 FillGrammarContent (list, g.Starts, g.Defines, g.Divs, g.Includes);
321 Grammar /* returns RelaxngGrammarContentList */
324 $$ = new RelaxngGrammarContentList ();
328 RelaxngGrammarContentList al = (RelaxngGrammarContentList) $2;
330 al.Insert (0, (IGrammarContent) $1);
335 Member /* returns nullable IGrammarContent (RelaxngDiv, RelaxngInclude, RelaxngStart, RelaxngDiv) */
338 $$ = (IGrammarContent) $1;
340 | AnnotationElementNotKeyword
346 AnnotatedComponent /* returns IGrammarContent */
347 : Annotations Component
349 // $$ = ApplyAnnotations ((string) $1, (RelaxngElementBase) $2);
350 $$ = (IGrammarContent) $2;
354 Component /* returns IGrammarContent */
357 $$ = (RelaxngStart) $1;
361 $$ = (RelaxngDefine) $1;
365 $$ = (RelaxngInclude) $1;
369 $$ = (RelaxngDiv) $1;
373 Start /* returns RelaxngStart */
374 : KeywordStart AssignOp Pattern
376 RelaxngStart start = new RelaxngStart ();
377 start.Combine = (string) $2;
378 start.Pattern = (RelaxngPattern) $3;
383 Define /* returns RelaxngDefine */
384 : Identifier AssignOp Pattern
386 RelaxngDefine def = new RelaxngDefine ();
387 def.Name = (string) $1;
388 def.Combine = (string) $2;
389 def.Patterns.Add ((RelaxngPattern) $3);
394 AssignOp /* returns string */
409 Include /* returns RelaxngInclude */
410 : KeywordInclude AnyURILiteral OptInherit OptIncludeBody
412 // FIXME: OptInherit is not handled properly.
413 RelaxngInclude include = new RelaxngInclude ();
414 include.Href = (string) $2;
415 include.NSContext = (string) $3;
416 FillGrammarContent ((IList) $4, include.Starts, include.Defines, include.Divs, null);
421 AnyURILiteral /* returns string */
424 // Constraints: any URI
429 OptInherit /* returns string */
430 /* FIXME: It is not handled properly. */
433 // MakeNsAttribute (LookupDefault (environment));
434 $$ = nsmgr.DefaultNamespace;
436 | KeywordInherit Equal IdentifierOrKeyword
438 // MakeNsAttribute (LookupPrefix (environment, $3));
439 $$ = nsmgr.LookupPrefix ((string) $3);
443 OptIncludeBody /* returns IList */
446 $$ = new ArrayList ();
448 | OpenCurly IncludeBody CloseCurly
454 IncludeBody /* returns IList */
457 $$ = new ArrayList ();
459 | IncludeMember IncludeBody
461 ArrayList al = (ArrayList) $2;
467 IncludeMember /* returns RelaxngElementBase */
468 : AnnotatedIncludeComponent
470 $$ = (RelaxngElementBase) $1;
472 | AnnotationElementNotKeyword
474 $$ = (RelaxngElementBase) $1;
478 AnnotatedIncludeComponent /* returns IGrammarContent */
479 : Annotations IncludeComponent
481 // $$ = ApplyAnnotations ((string) $1, (RelaxngElementBase) $2);
482 $$ = (IGrammarContent) $2;
486 IncludeComponent /* returns IGrammarContent */
489 $$ = (RelaxngStart) $1;
493 $$ = (RelaxngDefine) $1;
497 $$ = (RelaxngDiv) $1;
501 Div /* returns RelaxngDiv */
502 : KeywordDiv OpenCurly Grammar CloseCurly
504 RelaxngDiv div = new RelaxngDiv ();
505 FillGrammarContent ((IList) $3, div.Starts, div.Defines, div.Divs, div.Includes);
510 IncludeDiv /* returns RelaxngDiv */
511 : KeywordDiv OpenCurly IncludeBody CloseCurly
513 RelaxngDiv div = new RelaxngDiv ();
514 FillGrammarContent ((IList) $3, div.Starts, div.Defines, div.Divs, div.Includes);
519 Pattern /* returns RelaxngPattern */
523 InnerPattern /* returns RelaxngPattern */
524 /* TODO: applyAnnotations() are omitted */
527 $$ = (RelaxngPattern) $1;
531 RelaxngPatternList list = (RelaxngPatternList) $1;
532 RelaxngChoice choice = new RelaxngChoice ();
533 for (int i = 0; i < list.Count; i++)
534 choice.Patterns.Add (list [i]);
535 // This is said as to return Elements, while ApplyAnnotations() is said to return Element
540 RelaxngPatternList list = (RelaxngPatternList) $1;
541 RelaxngGroup group = new RelaxngGroup ();
542 for (int i = 0; i < list.Count; i++)
543 group.Patterns.Add (list [i]);
544 // This is said as to return Elements, while ApplyAnnotations() is said to return Element
549 RelaxngPatternList list = (RelaxngPatternList) $1;
550 RelaxngInterleave interleave = new RelaxngInterleave ();
551 for (int i = 0; i < list.Count; i++)
552 interleave.Patterns.Add (list [i]);
553 // This is said as to return Elements, while ApplyAnnotations() is said to return Element
556 | AnnotatedDataExcept
558 $$ = (RelaxngData) $1;
562 ParticleChoice /* returns RelaxngPatternList */
563 : Particle Bar Particle
565 RelaxngPatternList list = new RelaxngPatternList ();
566 list.Add ((RelaxngPattern) $1);
567 list.Add ((RelaxngPattern) $3);
570 | Particle Bar ParticleChoice
572 RelaxngPatternList list = (RelaxngPatternList) $3;
573 list.Insert (0, (RelaxngPattern) $1);
578 ParticleGroup /* returns RelaxngPatternList */
579 : Particle Comma Particle
581 RelaxngPatternList list = new RelaxngPatternList ();
582 list.Add ((RelaxngPattern) $1);
583 list.Add ((RelaxngPattern) $3);
586 | Particle Comma ParticleGroup
588 RelaxngPatternList list = (RelaxngPatternList) $3;
589 list.Insert (0, (RelaxngPattern) $1);
594 ParticleInterleave /* returns RelaxngPatternList */
595 : Particle Amp Particle
597 RelaxngPatternList list = new RelaxngPatternList ();
598 list.Add ((RelaxngPattern) $1);
599 list.Add ((RelaxngPattern) $3);
602 | Particle Amp ParticleInterleave
604 RelaxngPatternList list = (RelaxngPatternList) $3;
605 list.Insert (0, (RelaxngPattern) $1);
610 Particle /* returns RelaxngPattern */
614 InnerParticle /* returns RelaxngPattern */
617 // $$ = ApplyAnnotationsGroup (null, (RelaxngPatternList) $1);
620 | RepeatedPrimary FollowAnnotations
622 // FIXME: annotations are not handled
623 RelaxngPattern p = (RelaxngPattern) $1;
624 // RelaxngPatternList l = new RelaxngPatternList ();
631 RepeatedPrimary /* returns RelaxngPattern */
632 : AnnotatedPrimary Asterisk
634 RelaxngZeroOrMore zom = new RelaxngZeroOrMore ();
635 // foreach (RelaxngPattern p in (ICollection) $1)
636 // zom.Patterns.Add (p);
637 zom.Patterns.Add ((RelaxngPattern) $1);
640 | AnnotatedPrimary Plus
642 RelaxngOneOrMore oom = new RelaxngOneOrMore ();
643 // foreach (RelaxngPattern p in (ICollection) $1)
644 // oom.Patterns.Add (p);
645 oom.Patterns.Add ((RelaxngPattern) $1);
648 | AnnotatedPrimary Question
650 RelaxngOptional opt = new RelaxngOptional ();
651 // foreach (RelaxngPattern p in (ICollection) $1)
652 // opt.Patterns.Add (p);
653 opt.Patterns.Add ((RelaxngPattern) $1);
658 AnnotatedPrimary /* returns RelaxngPattern */
659 : LeadAnnotatedPrimary FollowAnnotations
661 // FIXME: handle followAnnotations
666 AnnotatedDataExcept /* returns RelaxngPatternList */
667 : LeadAnnotatedDataExcept FollowAnnotations
669 // FIXME: handle followAnnotations
670 RelaxngData p = (RelaxngData) $1;
671 RelaxngPatternList l = new RelaxngPatternList ();
677 LeadAnnotatedDataExcept /* returns RelaxngData */
678 : Annotations DataExcept
684 LeadAnnotatedPrimary /* returns RelaxngPattern */
685 : Annotations Primary
687 // LAMESPEC: This should return Elements, while ApplyAnnotations() returns Element
688 // RelaxngPatternList list = new RelaxngPatternList ();
689 // list.Add ((RelaxngPattern) ApplyAnnotations ((string) $1, (RelaxngPattern) $2));
691 $$ = (RelaxngPattern) $2;
693 | Annotations OpenParen InnerPattern CloseParen
695 // $$ = (RelaxngPatternList) $3;
696 $$ = (RelaxngPattern) $3;
700 Primary /* returns RelaxngPattern */
701 : KeywordElement NameClass OpenCurly Pattern CloseCurly
703 RelaxngNameClass nc = (RelaxngNameClass) $2;
704 RelaxngElement el = new RelaxngElement ();
706 FillElementDefaultNS (el.NameClass);
708 // foreach (RelaxngPattern p in (RelaxngPatternList) $4)
709 // el.Patterns.Add (p);
710 el.Patterns.Add ((RelaxngPattern) $4);
713 | KeywordAttribute NameClass OpenCurly Pattern CloseCurly
715 RelaxngNameClass nc = (RelaxngNameClass) $2;
717 RelaxngAttribute attr = new RelaxngAttribute ();
719 FillAttributeDefaultNS (attr.NameClass);
720 attr.Pattern = (RelaxngPattern) $4;
723 | KeywordMixed OpenCurly Pattern CloseCurly
725 RelaxngMixed mixed = new RelaxngMixed ();
726 foreach (RelaxngPattern p in (RelaxngPatternList) $3)
727 mixed.Patterns.Add (p);
730 | KeywordList OpenCurly Pattern CloseCurly
732 RelaxngList list = new RelaxngList ();
733 foreach (RelaxngPattern p in (RelaxngPatternList) $3)
734 list.Patterns.Add (p);
737 | DatatypeName OptParams
739 RelaxngData data = new RelaxngData ();
740 XmlQualifiedName dtName = (XmlQualifiedName) $1;
741 data.DatatypeLibrary = dtName.Namespace;
742 data.Type = dtName.Name;
743 foreach (RelaxngParam p in (ICollection) $2)
744 data.ParamList.Add (p);
748 | DatatypeName DatatypeValue
750 RelaxngValue value = new RelaxngValue ();
751 XmlQualifiedName dtName = (XmlQualifiedName) $1;
752 if (dtName.Namespace != RelaxngGrammar.NamespaceURI)
753 value.DatatypeLibrary = dtName.Namespace;
754 value.Type = dtName.Name;
755 value.Value = (string) $2;
761 RelaxngValue value = new RelaxngValue ();
762 value.Value = (string) $1;
764 // RELAX NG default type
765 value.Type = "string";
766 value.DatatypeLibrary = String.Empty;
772 $$ = new RelaxngEmpty ();
776 $$ = new RelaxngNotAllowed ();
780 $$ = new RelaxngText ();
784 RelaxngRef r = new RelaxngRef ();
785 r.Name = (string) $1;
790 RelaxngParentRef pref = new RelaxngParentRef ();
791 pref.Name = (string) $2;
794 | KeywordGrammar OpenCurly Grammar CloseCurly
796 RelaxngGrammar g = new RelaxngGrammar ();
797 FillGrammarContent ((IList) $3, g.Starts, g.Defines, g.Divs, g.Includes);
800 | KeywordExternal AnyURILiteral OptInherit
802 RelaxngExternalRef extref = new RelaxngExternalRef ();
803 extref.Href = (string) $2;
804 extref.NSContext = (string) $3;
809 DataExcept /* returns RelaxngData */
810 : DatatypeName OptParams Minus LeadAnnotatedPrimary
812 RelaxngData data = new RelaxngData ();
813 foreach (RelaxngParam p in (IList) $2)
814 data.ParamList.Add (p);
815 data.Except = new RelaxngExcept ();
816 foreach (RelaxngPattern p in (RelaxngPatternList) $4)
817 data.Except.Patterns.Add (p);
822 Ref /* returns string */
829 string cname = (string) $1;
831 int colonAt = cname.IndexOf (':');
832 string local = cname.Substring (colonAt + 1);
833 string prefix = cname.Substring (0, colonAt);
834 string ns = dtnsmgr.LookupNamespace (prefix);
835 $$ = new XmlQualifiedName (local, ns);
837 $$ = SplitQName (dtnsmgr, cname);
841 $$ = new XmlQualifiedName ("string", String.Empty);
845 $$ = new XmlQualifiedName ("token", String.Empty);
856 $$ = new RelaxngParamList ();
858 | OpenCurly Params CloseCurly
867 $$ = new RelaxngParamList ();
871 RelaxngParamList al = (RelaxngParamList) $2;
872 al.Insert (0, (RelaxngParam) $1);
877 Param /* returns RelaxngParam */
878 : Annotations IdentifierOrKeyword Equal Literal
880 RelaxngParam prm = new RelaxngParam ();
881 prm.Name = (string) $2;
882 prm.Value = (string) $4;
884 // $$ = ApplyAnnotations ((string) $1, prm);
889 NameClass /* returns RelaxngNameClass */
896 InnerNameClass /* returns RelaxngNameClass */
897 : AnnotatedSimpleNameClass
899 $$ = (RelaxngNameClass) $1;
903 RelaxngNameChoice cho = new RelaxngNameChoice ();
904 RelaxngNameClassList list = (RelaxngNameClassList) $1;
905 for (int i = 0; i < list.Count; i++)
906 cho.Children.Add ((RelaxngNameClass) list [i]);
909 | AnnotatedExceptNameClass
911 $$ = (RelaxngNameClass) $1;
915 NameClassChoice /* returns RelaxngNameClassList */
916 : AnnotatedSimpleNameClass Bar AnnotatedSimpleNameClass
918 RelaxngNameClassList list = new RelaxngNameClassList ();
919 list.Add ((RelaxngNameClass) $1);
920 list.Add ((RelaxngNameClass) $3);
923 | AnnotatedSimpleNameClass Bar NameClassChoice
925 RelaxngNameClassList list = (RelaxngNameClassList) $3;
926 list.Insert (0, (RelaxngNameClass) $1);
931 AnnotatedExceptNameClass /* returns RelaxngNameClass */
932 : LeadAnnotatedExceptNameClass FollowAnnotations
934 $$ = (RelaxngNameClass) $1;
938 LeadAnnotatedExceptNameClass /* returns RelaxngNameClass */
939 : Annotations ExceptNameClass
941 $$ = (RelaxngNameClass) $2;
945 AnnotatedSimpleNameClass /* returns RelaxngNameClass */
946 : LeadAnnotatedSimpleNameClass FollowAnnotations
948 // FIXME: annotations
953 LeadAnnotatedSimpleNameClass /* returns RelaxngNameClass */
954 : Annotations SimpleNameClass
956 // FIXME: applyAnnotations
957 $$ = (RelaxngNameClass) $2;
959 | Annotations OpenParen InnerNameClass CloseParen
966 : NsName Minus LeadAnnotatedSimpleNameClass
968 RelaxngNsName nsName = new RelaxngNsName ();
969 nsName.Namespace = nsmgr.LookupNamespace ((string) $1);
970 nsName.Except = new RelaxngExceptNameClass ();
971 nsName.Except.Names.Add ((RelaxngNameClass) $3);
974 | Asterisk Minus LeadAnnotatedSimpleNameClass
976 RelaxngAnyName anyName = new RelaxngAnyName ();
977 anyName.Except = new RelaxngExceptNameClass ();
978 anyName.Except.Names.Add ((RelaxngNameClass) $3);
983 SimpleNameClass /* returns RelaxngNameClass */
984 : IdentifierOrKeyword
986 RelaxngName name = new RelaxngName ();
987 name.LocalName = (string) $1;
988 name.Namespace = null;
993 string cname = (string) $1;
994 // int colonAt = cname.IndexOf (':');
995 // XmlQualifiedName qname = new XmlQualifiedName (cname.Substring (colonAt + 1), nsmgr.LookupNamespace (cname.Substring (0, colonAt - 1)));
996 XmlQualifiedName qname = SplitQName (nsmgr, cname);
997 RelaxngName name = new RelaxngName ();
998 name.LocalName = qname.Name;
999 name.Namespace = qname.Namespace;
1004 RelaxngNsName nsName = new RelaxngNsName ();
1005 nsName.Namespace = nsmgr.LookupNamespace ((string) $1);
1010 $$ = new RelaxngAnyName ();
1019 | TwoGreaters AnnotationElement FollowAnnotations
1021 // FIXME: handle them
1026 Annotations /* returns null */
1027 /* FIXME: needed to handle them? */
1032 | Documentations OpenCurly AnnotationAttributes AnnotationElements CloseCurly
1038 AnnotationAttributes /* returns null */
1043 | ForeignAttributeName Equal Literal AnnotationAttributes
1045 // Constraint: duplicate attributes
1047 // FIXME: do something
1052 ForeignAttributeName /* returns XmlQualifiedName */
1055 // Constraint: xmlns namespace URI
1056 // Constraint: unqualified name
1057 // Constraint: RELAX NG namespace URI
1066 | AnnotationElement AnnotationElements
1070 : ForeignElementName AnnotationAttributesContent
1073 // $$ = Element ($1, $2);
1079 : /*IdentifierOrKeyword
1081 $$ = new XmlQualifiedName ((string) $1, String.Empty);
1085 // Constraint: RELAX NG namespace URI
1090 AnnotationElementNotKeyword /* returns null */
1091 : ForeignElementNameNotKeyword AnnotationAttributesContent
1094 // $$ = Element ($1, $2);
1098 ForeignElementNameNotKeyword /* returns XmlQualifiedName */
1099 /* LAMESPEC: unprefixed Identifier causes conflict */
1102 $$ = new XmlQualifiedName ((string) $1, String.Empty);
1106 // Constraint: RELAX NG namespace URI
1107 $$ = (XmlQualifiedName) $1;
1111 AnnotationAttributesContent /* returns null */
1112 : OpenBracket NestedAnnotationAttributes AnnotationContent CloseBracket
1118 NestedAnnotationAttributes /* returns null */
1123 | AnyAttributeName Equal Literal NestedAnnotationAttributes
1125 // Constraint: duplicate attributes
1128 // $$ = Attribute ($1, $2);
1132 AnyAttributeName /* returns XmlQualifiedName */
1133 : IdentifierOrKeyword
1135 $$ = new XmlQualifiedName ((string) $1);
1139 // Constraint: xmlns namespace URI
1140 $$ = (XmlQualifiedName) $1;
1144 AnnotationContent /* returns null */
1149 | NestedAnnotationElement AnnotationContent
1153 | Literal AnnotationContent
1159 NestedAnnotationElement /* returns null */
1160 : AnyElementName AnnotationAttributesContent
1163 // $$ = Element ($1, $2);
1168 AnyElementName /* returns XmlQualifiedName */
1169 : IdentifierOrKeyword
1171 $$ = new XmlQualifiedName ((string) $1, String.Empty);
1175 $$ = (XmlQualifiedName) $1;
1179 PrefixedName /* returns XmlQualifiedName */
1182 // Constraint: annotation inherit
1183 $$ = SplitQName (nsmgr, (string) $1);
1187 Documentations /* returns null */
1192 | Documentation Documentations
1195 // $$ = Element (DocumentationElementName (), Text ((string) $1), $2);
1200 IdentifierOrKeyword /* returns string */
1211 Keyword /* returns string */
1233 Literal /* returns string */
1238 | LiteralSegment Tilde Literal
1240 $$ = (string) $1 + (string) $3;
1244 Identifier /* returns string */
1249 | BackSlash NCNameButKeyword