diff --git a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java
index da3254a24815..ebcacc5b9fed 100644
--- a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java
+++ b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java
@@ -670,6 +670,15 @@ public class XmlParsingTest extends ParsingTestCase {
doTest("", "test.html");
}
+ public void testKeywordsAsName() throws Exception {
+ doTestDtd("\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "");
+
+ }
+
static class MyLanguage extends Language implements InjectableLanguage {
protected MyLanguage() {
super("MyLanguage", "application/custom");
diff --git a/xml/tests/testData/psi/testEmptyElementsInDtd.txt b/xml/tests/testData/psi/testEmptyElementsInDtd.txt
index 98de113e9b09..5fc67a3373fa 100644
--- a/xml/tests/testData/psi/testEmptyElementsInDtd.txt
+++ b/xml/tests/testData/psi/testEmptyElementsInDtd.txt
@@ -4,7 +4,7 @@ XmlFile:test.dtd
PsiElement(XML_ELEMENT_DECL)
XmlToken:XML_ELEMENT_DECL_START('
PsiWhiteSpace(' ')
XmlToken:XML_TAG_END('>')
@@ -17,14 +17,14 @@ XmlFile:test.dtd
PsiElement(XML_ELEMENT_CONTENT_SPEC)
PsiElement(XML_ELEMENT_CONTENT_GROUP)
XmlToken:XML_LEFT_PAREN('(')
- PsiErrorElement:Xml name or entity ref expected
+ PsiErrorElement:XML name or entity ref expected
XmlToken:XML_COMMA(',')
XmlToken:XML_RIGHT_PAREN(')')
PsiWhiteSpace('\n')
PsiElement(XML_ATTLIST_DECL)
XmlToken:XML_ATTLIST_DECL_START('
PsiWhiteSpace(' ')
XmlToken:XML_TAG_END('>')
@@ -57,7 +57,7 @@ XmlFile:test.dtd
XmlToken:XML_LEFT_PAREN('(')
XmlToken:XML_NAME('aaa')
XmlToken:XML_COMMA(',')
- PsiErrorElement:Xml name or entity ref expected
+ PsiErrorElement:XML name or entity ref expected
XmlToken:XML_RIGHT_PAREN(')')
XmlToken:XML_TAG_END('>')
diff --git a/xml/tests/testData/psi/testEntityDeclaration.txt b/xml/tests/testData/psi/testEntityDeclaration.txt
index e8b81a6e4c48..e328434c7919 100644
--- a/xml/tests/testData/psi/testEntityDeclaration.txt
+++ b/xml/tests/testData/psi/testEntityDeclaration.txt
@@ -13,7 +13,7 @@ XmlFile:test.dtd
PsiWhiteSpace(' ')
PsiElement(XML_ENTITY_DECL)
XmlToken:XML_ENTITY_DECL_START('
PsiWhiteSpace(' ')
XmlToken:XML_TAG_END('>')
\ No newline at end of file
diff --git a/xml/tests/testData/psi/testKeywordsAsName.txt b/xml/tests/testData/psi/testKeywordsAsName.txt
new file mode 100644
index 000000000000..56cc129522cd
--- /dev/null
+++ b/xml/tests/testData/psi/testKeywordsAsName.txt
@@ -0,0 +1,58 @@
+XmlFile:test.dtd
+ PsiElement(XML_DOCUMENT)
+ PsiElement(XML_PROLOG)
+
+ PsiElement(XML_ELEMENT_DECL)
+ XmlToken:XML_ELEMENT_DECL_START('')
+ PsiWhiteSpace('\n')
+ PsiElement(XML_ELEMENT_DECL)
+ XmlToken:XML_ELEMENT_DECL_START('')
+ PsiWhiteSpace('\n')
+ PsiElement(XML_ELEMENT_DECL)
+ XmlToken:XML_ELEMENT_DECL_START('')
+ PsiWhiteSpace('\n')
+ PsiElement(XML_ELEMENT_DECL)
+ XmlToken:XML_ELEMENT_DECL_START('')
+ PsiWhiteSpace('\n')
+ PsiElement(XML_ELEMENT_DECL)
+ XmlToken:XML_ELEMENT_DECL_START('')
\ No newline at end of file
diff --git a/xml/xml-psi-impl/resources/messages/XmlErrorMessages.properties b/xml/xml-psi-impl/resources/messages/XmlErrorMessages.properties
index 5dba19c82294..2f90357d2e09 100644
--- a/xml/xml-psi-impl/resources/messages/XmlErrorMessages.properties
+++ b/xml/xml-psi-impl/resources/messages/XmlErrorMessages.properties
@@ -79,15 +79,15 @@ xml.declaration.should.precede.all.document.content=Xml declaration should prece
dtd.parser.message.whitespace.expected=Whitespace expected
dtd.parser.message.left.paren.or.entityref.or.empty.or.any.expected=( or entity ref or EMPTY or ANY expected
-dtd.parser.message.name.expected=xml name expected
+dtd.parser.message.name.expected=XML name expected
dtd.parser.message.literal.public.system.expected=Literal, PUBLIC or SYSTEM expected
-dtd.parser.message.name.or.entity.ref.expected=Xml name or entity ref expected
+dtd.parser.message.name.or.entity.ref.expected=XML name or entity ref expected
dtd.parser.message.rbrace.expected=) expected
-duplicate.declaration=Nonunique declaration name {0}
+duplicate.declaration=Non-unique declaration name {0}
xml.validate.external.resource.is.not.registered=External resource {0} is not registered
xml.schema.validation.attr.not.allowed.with.ref=Attribute {0} is not allowed here when element reference is used
xml.schema.validation.max.occurs.should.be.not.less.than.min.occurs=maxOccurs value should be greater than minOccurs value
xml.schema.validation.name.or.ref.should.present=Either 'name' or 'ref' attribute should present
-xml.schema.validation.default.or.fixed.should.be.specified.but.not.both='default' and 'fixed' attributes should not bepresent in the same time
+xml.schema.validation.default.or.fixed.should.be.specified.but.not.both='default' and 'fixed' attributes should not be present in the same time
diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java
index 27c63443723d..8819dc30da42 100644
--- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java
+++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/parsing/xml/DtdParsing.java
@@ -94,7 +94,7 @@ public class DtdParsing extends XmlParsing implements XmlElementType {
parseGenericXml();
break;
case ELEMENT_CONTENT_SPEC:
- parseElementContentSpec();
+ doParseContentSpec(true);
break;
case ATTLIST_SPEC:
parseAttlistContent();
@@ -492,22 +492,28 @@ public class DtdParsing extends XmlParsing implements XmlElementType {
}
private boolean parseName() {
- if (myBuilder.getTokenType() == XML_NAME) {
+ IElementType type = myBuilder.getTokenType();
+ if (type == XML_NAME) {
addToken();
return true;
}
- if (myBuilder.getTokenType() == XML_ENTITY_REF_TOKEN) {
+ if (type == XML_ENTITY_REF_TOKEN) {
parseEntityRef();
return true;
}
- return false;
+ return consumeKeywordAsName(type);
}
- private void parseElementContentSpec() {
- doParseContentSpec(true);
+ private boolean consumeKeywordAsName(IElementType type) {
+ if (type == XML_DOCTYPE_PUBLIC || type == XML_DOCTYPE_SYSTEM || type == XML_CONTENT_EMPTY || type == XML_CONTENT_ANY) {
+ myBuilder.remapCurrentToken(XML_NAME);
+ addToken();
+ return true;
+ }
+ return false;
}
private void doParseContentSpec(boolean topLevel) {
@@ -569,6 +575,9 @@ public class DtdParsing extends XmlParsing implements XmlElementType {
addToken();
endedWithDelimiter = false;
}
+ else if (consumeKeywordAsName(tokenType)) {
+ endedWithDelimiter = false;
+ }
else {
myBuilder.error(XmlErrorMessages.message("dtd.parser.message.name.or.entity.ref.expected"));
return false;
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java
index 6d01ce8bc65f..5e144f7bdc4f 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/impl/dtd/BaseXmlElementDescriptorImpl.java
@@ -142,4 +142,9 @@ public abstract class BaseXmlElementDescriptorImpl implements XmlElementDescript
public final XmlAttributeDescriptor getAttributeDescriptor(XmlAttribute attr){
return getAttributeDescriptor(attr.getName(), attr.getParent());
}
+
+ @Override
+ public String toString() {
+ return getQualifiedName();
+ }
}