use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlInsightTest method testDocumentDescriptor1.
public void testDocumentDescriptor1() throws Exception {
XmlFile file = createFile("<root><a></a><b></b><a></a></root>");
XmlNSDescriptor descriptor = createDescriptor(file);
XmlElementDescriptor element = descriptor.getElementDescriptor(file.getDocument().getRootTag());
assertNotNull(element);
assertEquals("root", element.getName());
element = descriptor.getElementDescriptor(file.getDocument().getRootTag().getSubTags()[0]);
assertNotNull(element);
assertEquals("a", element.getName());
element = descriptor.getElementDescriptor(file.getDocument().getRootTag().getSubTags()[1]);
assertNotNull(element);
assertEquals("b", element.getName());
element = descriptor.getElementDescriptor(file.getDocument().getRootTag().getSubTags()[2]);
assertNotNull(element);
assertEquals("a", element.getName());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlDtdTest method testEntityDecl1.
public void testEntityDecl1() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % boolean \"(true|false|on|off|yes|no)\"> <!ELEMENT toc ANY> <!ATTLIST toc remote %boolean; \"false\"");
final XmlTag tag = tag("toc");
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("remote", tag);
assertTrue(!attributeDescriptor.isRequired());
assertTrue(!attributeDescriptor.isFixed());
assertTrue(attributeDescriptor.isEnumerated());
assertEquals("false", (attributeDescriptor.getDefaultValue()));
String[] values = attributeDescriptor.getEnumeratedValues();
assertEquals(6, values.length);
assertEquals("true", values[0]);
assertEquals("false", values[1]);
assertEquals("on", values[2]);
assertEquals("off", values[3]);
assertEquals("yes", values[4]);
assertEquals("no", values[5]);
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlDtdTest method testEntityDecl4.
public void testEntityDecl4() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % boolean \'(true|false|on|off|yes|no)\'> <!ENTITY % bool \"%boolean;\"> <!ELEMENT toc ANY> <!ATTLIST toc remote %bool; \"false\"");
final XmlTag tag = tag("toc");
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("remote", tag);
assertTrue(!attributeDescriptor.isRequired());
assertTrue(!attributeDescriptor.isFixed());
assertTrue(attributeDescriptor.isEnumerated());
assertEquals("false", attributeDescriptor.getDefaultValue());
String[] values = attributeDescriptor.getEnumeratedValues();
assertEquals(6, values.length);
assertEquals("true", values[0]);
assertEquals("false", values[1]);
assertEquals("on", values[2]);
assertEquals("off", values[3]);
assertEquals("yes", values[4]);
assertEquals("no", values[5]);
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlDtdTest method testEntityDecl3.
public void testEntityDecl3() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % att1 \"id1 D #IMPLIED\"> <!ENTITY % att2 \"id2 D #IMPLIED\"> <!ELEMENT a ANY> <!ATTLIST a %att1; %att2; ");
final XmlTag tag = tag("a");
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
final XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
assertEquals(2, attributes.length);
assertEquals("id1", attributes[0].getName());
assertEquals("id2", attributes[1].getName());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlDtdTest method testElementDescriptor1.
public void testElementDescriptor1() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT principals (#PCDATA)><!ELEMENT data-sources (#PCDATA)>");
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag("principals"));
assertEquals("principals", elementDescriptor.getName());
elementDescriptor = NSDescriptor.getElementDescriptor(tag("data-sources"));
assertEquals("data-sources", elementDescriptor.getName());
}
Aggregations