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;
60 static int yacc_verbose_flag;
62 RncTokenizer tokenizer;
64 public RncParser (XmlNameTable nameTable)
66 nsmgr = new XmlNamespaceManager (nameTable);
67 dtnsmgr = new XmlNamespaceManager (nameTable);
68 ErrorOutput = System.IO.TextWriter.Null;
72 get { return tokenizer.Line; }
76 get { return tokenizer.Column; }
79 // note that this is different notion than that of xmlns.
80 public string DefaultNamespace {
81 get { return defaultNamespace; }
84 public RelaxngPattern Parse (TextReader source)
87 // debug = new yydebug.yyDebugSimple ();
88 tokenizer = new RncTokenizer (source);
89 return (RelaxngPattern) yyparse (tokenizer);
90 } catch (Exception ex) {
\r
91 throw new RelaxngException (String.Format ("Tokenizer error at line {0}, column {1}: {2}", Line, Column, ex.Message), ex);
\r
96 private void FillGrammarContent (IList source, IList starts, IList defines, IList divs, IList includes)
98 foreach (RelaxngElementBase elem in source) {
99 if (elem is RelaxngStart)
101 else if (elem is RelaxngDefine)
103 else if (elem is RelaxngDiv)
105 else if (elem is RelaxngInclude)
108 throw new InvalidOperationException ();
112 private XmlQualifiedName SplitQName (XmlNamespaceManager nsmgr, string name)
114 int colon = name.IndexOf (':');
116 return new XmlQualifiedName (name, String.Empty);
117 string local = name.Substring (colon + 1);
118 string prefix = name.Substring (0, colon);
119 return new XmlQualifiedName (local, nsmgr.LookupNamespace (nsmgr.NameTable.Get (prefix)));
122 private void FillElementDefaultNS (RelaxngNameClass nc)
124 RelaxngName name = nc as RelaxngName;
126 if (name.Namespace == null)
127 name.Namespace = this.DefaultNamespace;
130 RelaxngNameChoice choice = nc as RelaxngNameChoice;
131 if (choice != null) {
132 foreach (RelaxngNameClass c in choice.Children)
133 FillElementDefaultNS (c);
137 private void FillAttributeDefaultNS (RelaxngNameClass nc)
139 RelaxngName name = nc as RelaxngName;
141 if (name.Namespace == null)
142 name.Namespace = String.Empty;
145 RelaxngNameChoice choice = nc as RelaxngNameChoice;
146 if (choice != null) {
147 foreach (RelaxngNameClass c in choice.Children)
148 FillAttributeDefaultNS (c);
157 %token KeywordAttribute "attribute"
158 %token KeywordDefault //"default"
159 %token KeywordDatatypes "datatypes"
160 %token KeywordDiv "div"
161 %token KeywordElement "element"
162 %token KeywordEmpty "empty"
163 %token KeywordExternal "external"
164 %token KeywordGrammar "grammar"
165 %token KeywordInclude "include"
166 %token KeywordInherit "inherit"
167 %token KeywordList "list"
168 %token KeywordMixed "mixed"
169 %token KeywordNamespace //"namespace"
170 %token KeywordNotAllowed "notAllowed"
171 %token KeywordParent "parent"
172 %token KeywordStart "start"
173 %token KeywordString //"string"
174 %token KeywordText "text"
175 %token KeywordToken "left"
181 %token CloseCurly "}"
183 %token CloseParen ")"
184 %token OpenBracket "["
185 %token CloseBracket "]"
190 %token BackSlash "\\"
194 %token AndEquals "&="
195 %token TwoGreaters ">>"
197 %token LiteralSegment
198 %token NCNameButKeyword
202 /* These tokens are parsed by RncTokenizer, since whitespaces between
203 the particles are not allowed. */
213 TopLevel /* returns RelaxngPattern */
214 /* TODO: here Annotations is not specified in the spec!! */
215 : Annotations TopLevelAfterAnnotations
217 $$ = (RelaxngPattern) $2;
221 TopLevelAfterAnnotations /* returns RelaxngPattern */
222 /* TODO: here Annotations is not specified in the spec!! */
223 : Preamble TopLevelBody
225 $$ = (RelaxngPattern) $2;
229 Preamble /* returns null */
240 Decl /* returns null */
241 : KeywordNamespace NamespacePrefix Equal NamespaceURILiteral
244 string prefix = (string) $2;
245 string ns = (string) $4;
246 if (prefix == "local")
247 nsmgr.AddNamespace (String.Empty, ns);
249 nsmgr.AddNamespace (prefix, ns);
252 | KeywordDefault KeywordNamespace Equal NamespaceURILiteral
255 string ns = (string) $4;
256 defaultNamespace = ns;
259 | KeywordDefault KeywordNamespace NamespacePrefix Equal NamespaceURILiteral
262 string prefix = (string) $3;
263 string ns = (string) $5;
264 defaultNamespace = ns;
265 nsmgr.AddNamespace (prefix, ns);
268 | KeywordDatatypes DatatypePrefix Equal Literal
271 string prefix = (string) $2;
272 string ns = (string) $4;
273 dtnsmgr.AddNamespace (prefix, ns);
278 NamespacePrefix /* returns string */
279 : IdentifierOrKeyword
285 DatatypePrefix /* returns string */
286 : IdentifierOrKeyword
292 NamespaceURILiteral /* returns string */
303 TopLevelBody /* returns RelaxngPattern */
306 // TODO: Constraint: single element
307 // IList pl = (IList) $1;
308 // if (pl.Count != 1)
309 // throw new RelaxngException ("The number of the top level pattern must be exactly one.");
311 $$ = (RelaxngPattern) $1;
315 RelaxngGrammar g = new RelaxngGrammar ();
316 RelaxngGrammarContentList list = (RelaxngGrammarContentList) $1;
317 FillGrammarContent (list, g.Starts, g.Defines, g.Divs, g.Includes);
322 Grammar /* returns RelaxngGrammarContentList */
325 $$ = new RelaxngGrammarContentList ();
329 RelaxngGrammarContentList al = (RelaxngGrammarContentList) $2;
331 al.Insert (0, (IGrammarContent) $1);
336 Member /* returns nullable IGrammarContent (RelaxngDiv, RelaxngInclude, RelaxngStart, RelaxngDiv) */
339 $$ = (IGrammarContent) $1;
341 | AnnotationElementNotKeyword
347 AnnotatedComponent /* returns IGrammarContent */
348 : Annotations Component
350 // $$ = ApplyAnnotations ((string) $1, (RelaxngElementBase) $2);
351 $$ = (IGrammarContent) $2;
355 Component /* returns IGrammarContent */
358 $$ = (RelaxngStart) $1;
362 $$ = (RelaxngDefine) $1;
366 $$ = (RelaxngInclude) $1;
370 $$ = (RelaxngDiv) $1;
374 Start /* returns RelaxngStart */
375 : KeywordStart AssignOp Pattern
377 RelaxngStart start = new RelaxngStart ();
378 start.Combine = (string) $2;
379 start.Pattern = (RelaxngPattern) $3;
384 Define /* returns RelaxngDefine */
385 : Identifier AssignOp Pattern
387 RelaxngDefine def = new RelaxngDefine ();
388 def.Name = (string) $1;
389 def.Combine = (string) $2;
390 def.Patterns.Add ((RelaxngPattern) $3);
395 AssignOp /* returns string */
410 Include /* returns RelaxngInclude */
411 : KeywordInclude AnyURILiteral OptInherit OptIncludeBody
413 // FIXME: OptInherit is not handled properly.
414 RelaxngInclude include = new RelaxngInclude ();
415 include.Href = (string) $2;
416 include.NSContext = (string) $3;
417 FillGrammarContent ((IList) $4, include.Starts, include.Defines, include.Divs, null);
422 AnyURILiteral /* returns string */
425 // Constraints: any URI
430 OptInherit /* returns string */
431 /* FIXME: It is not handled properly. */
434 // MakeNsAttribute (LookupDefault (environment));
435 $$ = nsmgr.DefaultNamespace;
437 | KeywordInherit Equal IdentifierOrKeyword
439 // MakeNsAttribute (LookupPrefix (environment, $3));
440 $$ = nsmgr.LookupPrefix ((string) $3);
444 OptIncludeBody /* returns IList */
447 $$ = new ArrayList ();
449 | OpenCurly IncludeBody CloseCurly
455 IncludeBody /* returns IList */
458 $$ = new ArrayList ();
460 | IncludeMember IncludeBody
462 ArrayList al = (ArrayList) $2;
468 IncludeMember /* returns RelaxngElementBase */
469 : AnnotatedIncludeComponent
471 $$ = (RelaxngElementBase) $1;
473 | AnnotationElementNotKeyword
475 $$ = (RelaxngElementBase) $1;
479 AnnotatedIncludeComponent /* returns IGrammarContent */
480 : Annotations IncludeComponent
482 // $$ = ApplyAnnotations ((string) $1, (RelaxngElementBase) $2);
483 $$ = (IGrammarContent) $2;
487 IncludeComponent /* returns IGrammarContent */
490 $$ = (RelaxngStart) $1;
494 $$ = (RelaxngDefine) $1;
498 $$ = (RelaxngDiv) $1;
502 Div /* returns RelaxngDiv */
503 : KeywordDiv OpenCurly Grammar CloseCurly
505 RelaxngDiv div = new RelaxngDiv ();
506 FillGrammarContent ((IList) $3, div.Starts, div.Defines, div.Divs, div.Includes);
511 IncludeDiv /* returns RelaxngDiv */
512 : KeywordDiv OpenCurly IncludeBody CloseCurly
514 RelaxngDiv div = new RelaxngDiv ();
515 FillGrammarContent ((IList) $3, div.Starts, div.Defines, div.Divs, div.Includes);
520 Pattern /* returns RelaxngPattern */
524 InnerPattern /* returns RelaxngPattern */
525 /* TODO: applyAnnotations() are omitted */
528 $$ = (RelaxngPattern) $1;
532 RelaxngPatternList list = (RelaxngPatternList) $1;
533 RelaxngChoice choice = new RelaxngChoice ();
534 for (int i = 0; i < list.Count; i++)
535 choice.Patterns.Add (list [i]);
536 // This is said as to return Elements, while ApplyAnnotations() is said to return Element
541 RelaxngPatternList list = (RelaxngPatternList) $1;
542 RelaxngGroup group = new RelaxngGroup ();
543 for (int i = 0; i < list.Count; i++)
544 group.Patterns.Add (list [i]);
545 // This is said as to return Elements, while ApplyAnnotations() is said to return Element
550 RelaxngPatternList list = (RelaxngPatternList) $1;
551 RelaxngInterleave interleave = new RelaxngInterleave ();
552 for (int i = 0; i < list.Count; i++)
553 interleave.Patterns.Add (list [i]);
554 // This is said as to return Elements, while ApplyAnnotations() is said to return Element
557 | AnnotatedDataExcept
559 $$ = (RelaxngData) $1;
563 ParticleChoice /* returns RelaxngPatternList */
564 : Particle Bar Particle
566 RelaxngPatternList list = new RelaxngPatternList ();
567 list.Add ((RelaxngPattern) $1);
568 list.Add ((RelaxngPattern) $3);
571 | Particle Bar ParticleChoice
573 RelaxngPatternList list = (RelaxngPatternList) $3;
574 list.Insert (0, (RelaxngPattern) $1);
579 ParticleGroup /* returns RelaxngPatternList */
580 : Particle Comma Particle
582 RelaxngPatternList list = new RelaxngPatternList ();
583 list.Add ((RelaxngPattern) $1);
584 list.Add ((RelaxngPattern) $3);
587 | Particle Comma ParticleGroup
589 RelaxngPatternList list = (RelaxngPatternList) $3;
590 list.Insert (0, (RelaxngPattern) $1);
595 ParticleInterleave /* returns RelaxngPatternList */
596 : Particle Amp Particle
598 RelaxngPatternList list = new RelaxngPatternList ();
599 list.Add ((RelaxngPattern) $1);
600 list.Add ((RelaxngPattern) $3);
603 | Particle Amp ParticleInterleave
605 RelaxngPatternList list = (RelaxngPatternList) $3;
606 list.Insert (0, (RelaxngPattern) $1);
611 Particle /* returns RelaxngPattern */
615 InnerParticle /* returns RelaxngPattern */
618 // $$ = ApplyAnnotationsGroup (null, (RelaxngPatternList) $1);
621 | RepeatedPrimary FollowAnnotations
623 // FIXME: annotations are not handled
624 RelaxngPattern p = (RelaxngPattern) $1;
625 // RelaxngPatternList l = new RelaxngPatternList ();
632 RepeatedPrimary /* returns RelaxngPattern */
633 : AnnotatedPrimary Asterisk
635 RelaxngZeroOrMore zom = new RelaxngZeroOrMore ();
636 // foreach (RelaxngPattern p in (ICollection) $1)
637 // zom.Patterns.Add (p);
638 zom.Patterns.Add ((RelaxngPattern) $1);
641 | AnnotatedPrimary Plus
643 RelaxngOneOrMore oom = new RelaxngOneOrMore ();
644 // foreach (RelaxngPattern p in (ICollection) $1)
645 // oom.Patterns.Add (p);
646 oom.Patterns.Add ((RelaxngPattern) $1);
649 | AnnotatedPrimary Question
651 RelaxngOptional opt = new RelaxngOptional ();
652 // foreach (RelaxngPattern p in (ICollection) $1)
653 // opt.Patterns.Add (p);
654 opt.Patterns.Add ((RelaxngPattern) $1);
659 AnnotatedPrimary /* returns RelaxngPattern */
660 : LeadAnnotatedPrimary FollowAnnotations
662 // FIXME: handle followAnnotations
667 AnnotatedDataExcept /* returns RelaxngPatternList */
668 : LeadAnnotatedDataExcept FollowAnnotations
670 // FIXME: handle followAnnotations
671 RelaxngData p = (RelaxngData) $1;
672 RelaxngPatternList l = new RelaxngPatternList ();
678 LeadAnnotatedDataExcept /* returns RelaxngData */
679 : Annotations DataExcept
685 LeadAnnotatedPrimary /* returns RelaxngPattern */
686 : Annotations Primary
688 // LAMESPEC: This should return Elements, while ApplyAnnotations() returns Element
689 // RelaxngPatternList list = new RelaxngPatternList ();
690 // list.Add ((RelaxngPattern) ApplyAnnotations ((string) $1, (RelaxngPattern) $2));
692 $$ = (RelaxngPattern) $2;
694 | Annotations OpenParen InnerPattern CloseParen
696 // $$ = (RelaxngPatternList) $3;
697 $$ = (RelaxngPattern) $3;
701 Primary /* returns RelaxngPattern */
702 : KeywordElement NameClass OpenCurly Pattern CloseCurly
704 RelaxngNameClass nc = (RelaxngNameClass) $2;
705 RelaxngElement el = new RelaxngElement ();
707 FillElementDefaultNS (el.NameClass);
709 // foreach (RelaxngPattern p in (RelaxngPatternList) $4)
710 // el.Patterns.Add (p);
711 el.Patterns.Add ((RelaxngPattern) $4);
714 | KeywordAttribute NameClass OpenCurly Pattern CloseCurly
716 RelaxngNameClass nc = (RelaxngNameClass) $2;
718 RelaxngAttribute attr = new RelaxngAttribute ();
720 FillAttributeDefaultNS (attr.NameClass);
721 attr.Pattern = (RelaxngPattern) $4;
724 | KeywordMixed OpenCurly Pattern CloseCurly
726 RelaxngMixed mixed = new RelaxngMixed ();
727 foreach (RelaxngPattern p in (RelaxngPatternList) $3)
728 mixed.Patterns.Add (p);
731 | KeywordList OpenCurly Pattern CloseCurly
733 RelaxngList list = new RelaxngList ();
734 foreach (RelaxngPattern p in (RelaxngPatternList) $3)
735 list.Patterns.Add (p);
738 | DatatypeName OptParams
740 RelaxngData data = new RelaxngData ();
741 XmlQualifiedName dtName = (XmlQualifiedName) $1;
742 data.DatatypeLibrary = dtName.Namespace;
743 data.Type = dtName.Name;
744 foreach (RelaxngParam p in (ICollection) $2)
745 data.ParamList.Add (p);
749 | DatatypeName DatatypeValue
751 RelaxngValue value = new RelaxngValue ();
752 XmlQualifiedName dtName = (XmlQualifiedName) $1;
753 if (dtName.Namespace != RelaxngGrammar.NamespaceURI)
754 value.DatatypeLibrary = dtName.Namespace;
755 value.Type = dtName.Name;
756 value.Value = (string) $2;
762 RelaxngValue value = new RelaxngValue ();
763 value.Value = (string) $1;
765 // RELAX NG default type
766 value.Type = "string";
767 value.DatatypeLibrary = String.Empty;
773 $$ = new RelaxngEmpty ();
777 $$ = new RelaxngNotAllowed ();
781 $$ = new RelaxngText ();
785 RelaxngRef r = new RelaxngRef ();
786 r.Name = (string) $1;
791 RelaxngParentRef pref = new RelaxngParentRef ();
792 pref.Name = (string) $2;
795 | KeywordGrammar OpenCurly Grammar CloseCurly
797 RelaxngGrammar g = new RelaxngGrammar ();
798 FillGrammarContent ((IList) $3, g.Starts, g.Defines, g.Divs, g.Includes);
801 | KeywordExternal AnyURILiteral OptInherit
803 RelaxngExternalRef extref = new RelaxngExternalRef ();
804 extref.Href = (string) $2;
805 extref.NSContext = (string) $3;
810 DataExcept /* returns RelaxngData */
811 : DatatypeName OptParams Minus LeadAnnotatedPrimary
813 RelaxngData data = new RelaxngData ();
814 foreach (RelaxngParam p in (IList) $2)
815 data.ParamList.Add (p);
816 data.Except = new RelaxngExcept ();
817 foreach (RelaxngPattern p in (RelaxngPatternList) $4)
818 data.Except.Patterns.Add (p);
823 Ref /* returns string */
830 string cname = (string) $1;
832 int colonAt = cname.IndexOf (':');
833 string local = cname.Substring (colonAt + 1);
834 string prefix = cname.Substring (0, colonAt);
835 string ns = dtnsmgr.LookupNamespace (prefix);
836 $$ = new XmlQualifiedName (local, ns);
838 $$ = SplitQName (dtnsmgr, cname);
842 $$ = new XmlQualifiedName ("string", String.Empty);
846 $$ = new XmlQualifiedName ("token", String.Empty);
857 $$ = new RelaxngParamList ();
859 | OpenCurly Params CloseCurly
868 $$ = new RelaxngParamList ();
872 RelaxngParamList al = (RelaxngParamList) $2;
873 al.Insert (0, (RelaxngParam) $1);
878 Param /* returns RelaxngParam */
879 : Annotations IdentifierOrKeyword Equal Literal
881 RelaxngParam prm = new RelaxngParam ();
882 prm.Name = (string) $2;
883 prm.Value = (string) $4;
885 // $$ = ApplyAnnotations ((string) $1, prm);
890 NameClass /* returns RelaxngNameClass */
897 InnerNameClass /* returns RelaxngNameClass */
898 : AnnotatedSimpleNameClass
900 $$ = (RelaxngNameClass) $1;
904 RelaxngNameChoice cho = new RelaxngNameChoice ();
905 RelaxngNameClassList list = (RelaxngNameClassList) $1;
906 for (int i = 0; i < list.Count; i++)
907 cho.Children.Add ((RelaxngNameClass) list [i]);
910 | AnnotatedExceptNameClass
912 $$ = (RelaxngNameClass) $1;
916 NameClassChoice /* returns RelaxngNameClassList */
917 : AnnotatedSimpleNameClass Bar AnnotatedSimpleNameClass
919 RelaxngNameClassList list = new RelaxngNameClassList ();
920 list.Add ((RelaxngNameClass) $1);
921 list.Add ((RelaxngNameClass) $3);
924 | AnnotatedSimpleNameClass Bar NameClassChoice
926 RelaxngNameClassList list = (RelaxngNameClassList) $3;
927 list.Insert (0, (RelaxngNameClass) $1);
932 AnnotatedExceptNameClass /* returns RelaxngNameClass */
933 : LeadAnnotatedExceptNameClass FollowAnnotations
935 $$ = (RelaxngNameClass) $1;
939 LeadAnnotatedExceptNameClass /* returns RelaxngNameClass */
940 : Annotations ExceptNameClass
942 $$ = (RelaxngNameClass) $2;
946 AnnotatedSimpleNameClass /* returns RelaxngNameClass */
947 : LeadAnnotatedSimpleNameClass FollowAnnotations
949 // FIXME: annotations
954 LeadAnnotatedSimpleNameClass /* returns RelaxngNameClass */
955 : Annotations SimpleNameClass
957 // FIXME: applyAnnotations
958 $$ = (RelaxngNameClass) $2;
960 | Annotations OpenParen InnerNameClass CloseParen
967 : NsName Minus LeadAnnotatedSimpleNameClass
969 RelaxngNsName nsName = new RelaxngNsName ();
970 nsName.Namespace = nsmgr.LookupNamespace ((string) $1);
971 nsName.Except = new RelaxngExceptNameClass ();
972 nsName.Except.Names.Add ((RelaxngNameClass) $3);
975 | Asterisk Minus LeadAnnotatedSimpleNameClass
977 RelaxngAnyName anyName = new RelaxngAnyName ();
978 anyName.Except = new RelaxngExceptNameClass ();
979 anyName.Except.Names.Add ((RelaxngNameClass) $3);
984 SimpleNameClass /* returns RelaxngNameClass */
985 : IdentifierOrKeyword
987 RelaxngName name = new RelaxngName ();
988 name.LocalName = (string) $1;
989 name.Namespace = null;
994 string cname = (string) $1;
995 // int colonAt = cname.IndexOf (':');
996 // XmlQualifiedName qname = new XmlQualifiedName (cname.Substring (colonAt + 1), nsmgr.LookupNamespace (cname.Substring (0, colonAt - 1)));
997 XmlQualifiedName qname = SplitQName (nsmgr, cname);
998 RelaxngName name = new RelaxngName ();
999 name.LocalName = qname.Name;
1000 name.Namespace = qname.Namespace;
1005 RelaxngNsName nsName = new RelaxngNsName ();
1006 nsName.Namespace = nsmgr.LookupNamespace ((string) $1);
1011 $$ = new RelaxngAnyName ();
1020 | TwoGreaters AnnotationElement FollowAnnotations
1022 // FIXME: handle them
1027 Annotations /* returns null */
1028 /* FIXME: needed to handle them? */
1033 | Documentations OpenCurly AnnotationAttributes AnnotationElements CloseCurly
1039 AnnotationAttributes /* returns null */
1044 | ForeignAttributeName Equal Literal AnnotationAttributes
1046 // Constraint: duplicate attributes
1048 // FIXME: do something
1053 ForeignAttributeName /* returns XmlQualifiedName */
1056 // Constraint: xmlns namespace URI
1057 // Constraint: unqualified name
1058 // Constraint: RELAX NG namespace URI
1067 | AnnotationElement AnnotationElements
1071 : ForeignElementName AnnotationAttributesContent
1074 // $$ = Element ($1, $2);
1080 : /*IdentifierOrKeyword
1082 $$ = new XmlQualifiedName ((string) $1, String.Empty);
1086 // Constraint: RELAX NG namespace URI
1091 AnnotationElementNotKeyword /* returns null */
1092 : ForeignElementNameNotKeyword AnnotationAttributesContent
1095 // $$ = Element ($1, $2);
1099 ForeignElementNameNotKeyword /* returns XmlQualifiedName */
1100 /* LAMESPEC: unprefixed Identifier causes conflict */
1103 $$ = new XmlQualifiedName ((string) $1, String.Empty);
1107 // Constraint: RELAX NG namespace URI
1108 $$ = (XmlQualifiedName) $1;
1112 AnnotationAttributesContent /* returns null */
1113 : OpenBracket NestedAnnotationAttributes AnnotationContent CloseBracket
1119 NestedAnnotationAttributes /* returns null */
1124 | AnyAttributeName Equal Literal NestedAnnotationAttributes
1126 // Constraint: duplicate attributes
1129 // $$ = Attribute ($1, $2);
1133 AnyAttributeName /* returns XmlQualifiedName */
1134 : IdentifierOrKeyword
1136 $$ = new XmlQualifiedName ((string) $1);
1140 // Constraint: xmlns namespace URI
1141 $$ = (XmlQualifiedName) $1;
1145 AnnotationContent /* returns null */
1150 | NestedAnnotationElement AnnotationContent
1154 | Literal AnnotationContent
1160 NestedAnnotationElement /* returns null */
1161 : AnyElementName AnnotationAttributesContent
1164 // $$ = Element ($1, $2);
1169 AnyElementName /* returns XmlQualifiedName */
1170 : IdentifierOrKeyword
1172 $$ = new XmlQualifiedName ((string) $1, String.Empty);
1176 $$ = (XmlQualifiedName) $1;
1180 PrefixedName /* returns XmlQualifiedName */
1183 // Constraint: annotation inherit
1184 $$ = SplitQName (nsmgr, (string) $1);
1188 Documentations /* returns null */
1193 | Documentation Documentations
1196 // $$ = Element (DocumentationElementName (), Text ((string) $1), $2);
1201 IdentifierOrKeyword /* returns string */
1212 Keyword /* returns string */
1234 Literal /* returns string */
1239 | LiteralSegment Tilde Literal
1241 $$ = (string) $1 + (string) $3;
1245 Identifier /* returns string */
1250 | BackSlash NCNameButKeyword