use of com.intellij.xml.XmlAttributeDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testAny4.
public void testAny4() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema targetNamespace=\"http://foo\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >" + " <xsd:element name=\"root\">" + " <xsd:complexType>" + " <xsd:anyAttribute namespace=\"##other\" processContents=\"skip\"/>" + " </xsd:complexType>" + " </xsd:element>" + "</xsd:schema>");
XmlFile xmlFile = (XmlFile) createFile("file.xml", "<root xmlns=\"http://foo\" a=\"1\">" + "</root>");
final XmlTag rootTag = xmlFile.getDocument().getRootTag();
XmlElementDescriptor rootDescriptor = NSDescriptor.getElementDescriptor(rootTag);
assertNotNull(rootDescriptor);
XmlAttribute attribute = rootTag.getAttribute("a", XmlUtil.EMPTY_URI);
assertNotNull(attribute);
XmlAttributeDescriptor aDescriptor = rootDescriptor.getAttributeDescriptor("a", rootTag);
assertNull(aDescriptor);
attribute = rootTag.getAttribute("a", "http://foo");
assertNull(attribute);
attribute = rootTag.getAttribute("a", XmlUtil.ANT_URI);
assertNull(attribute);
}
use of com.intellij.xml.XmlAttributeDescriptor in project intellij-community by JetBrains.
the class XmlInsightTest method testElementDescriptor4.
public void testElementDescriptor4() throws Exception {
XmlFile file = createFile("<root><a attr2=''></a><a attr1=''></a></root>");
XmlNSDescriptor descriptor = createDescriptor(file);
XmlTag rootTag = file.getDocument().getRootTag();
XmlElementDescriptor element = descriptor.getElementDescriptor(rootTag);
element = element.getElementsDescriptors(rootTag)[0];
XmlAttributeDescriptor[] attributes = element.getAttributesDescriptors(rootTag);
assertEquals(2, attributes.length);
assertEquals("attr1", attributes[0].getName());
assertEquals("attr2", attributes[1].getName());
}
use of com.intellij.xml.XmlAttributeDescriptor 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.XmlAttributeDescriptor 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.XmlAttributeDescriptor 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());
}
Aggregations