use of com.intellij.xml.XmlAttributeDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testAttributeDescriptorProhibited2.
public void testAttributeDescriptorProhibited2() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:complexType name=\"PurchaseOrderType\">" + " <xsd:complexContent>" + " <xsd:restriction base=\"PurchaseOrderType2\">" + " <xsd:attribute name=\"orderDate\" type=\"xsd:date\" use=\"prohibited\"/>" + " </xsd:restriction>" + " </xsd:complexContent>" + "</xsd:complexType>" + "<xsd:complexType name=\"PurchaseOrderType2\">" + " <xsd:sequence>" + " <xsd:attribute name=\"orderDate\" type=\"xsd:date\"/>" + " <xsd:attribute name=\"name\" type=\"xsd:string\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "</xsd:schema>");
final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
assertEquals(1, attributes.length);
assertEquals("name", attributes[0].getName());
}
use of com.intellij.xml.XmlAttributeDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor5.
public void testElementDescriptor5() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:complexType name=\"PurchaseOrderType\">" + " <xsd:sequence>" + " <xsd:element name=\"shipTo\" type=\"USAddress\"/>" + " <xsd:element name=\"billTo\" type=\"USAddress\"/>" + " <xsd:element name=\"items\" type=\"Items\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "<xsd:complexType name=\"USAddress\">" + " <xsd:sequence>" + " <xsd:element name=\"name\" type=\"xsd:string\"/>" + " <xsd:element name=\"street\" type=\"xsd:string\"/>" + " <xsd:element name=\"city\" type=\"xsd:string\"/>" + " <xsd:element name=\"state\" type=\"xsd:string\"/>" + " <xsd:element name=\"zip\" type=\"xsd:decimal\"/>" + " </xsd:sequence>" + " <xsd:attribute name=\"country\" type=\"xsd:NMTOKEN\" fixed=\"US\"/>" + "</xsd:complexType>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag).getElementDescriptor(SHIP_TO, null);
XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(5, elements.length);
assertEquals("name", elements[0].getName());
assertEquals("street", elements[1].getName());
assertEquals("city", elements[2].getName());
assertEquals("state", elements[3].getName());
assertEquals("zip", elements[4].getName());
final XmlTag context = tag.findFirstSubTag(elements[2].getName());
assertEquals(0, elements[2].getElementsDescriptors(context).length);
XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(context);
assertEquals(1, attributes.length);
assertEquals("country", attributes[0].getName());
}
use of com.intellij.xml.XmlAttributeDescriptor in project intellij-community by JetBrains.
the class XmlDtdTest method testEntityDecl2.
public void testEntityDecl2() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<!ENTITY % coreattrs \"id D #IMPLIED\"> <!ELEMENT a ANY> <!ATTLIST a %coreattrs; version CDATA #FIXED \"1.0\"");
final XmlTag tag = tag("a");
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
final XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
assertEquals(2, attributes.length);
assertEquals("id", attributes[0].getName());
assertEquals("version", attributes[1].getName());
}
use of com.intellij.xml.XmlAttributeDescriptor in project intellij-community by JetBrains.
the class XmlDtdTest method testAttributeDescriptor4.
public void testAttributeDescriptor4() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT toc ANY> <!ATTLIST toc remote (true|false) \"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(2, values.length);
assertEquals("true", values[0]);
assertEquals("false", values[1]);
}
use of com.intellij.xml.XmlAttributeDescriptor in project intellij-community by JetBrains.
the class XmlDtdTest method testAttributeDescriptor1.
public void testAttributeDescriptor1() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<!ELEMENT principals ANY><!ATTLIST principals path CDATA #IMPLIED>");
final XmlTag tag = tag("principals");
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor attributeDescriptor = elementDescriptor.getAttributeDescriptor("path", tag);
assertEquals("path", attributeDescriptor.getName());
assertTrue(!attributeDescriptor.isRequired());
assertTrue(!attributeDescriptor.isFixed());
assertTrue(!attributeDescriptor.isEnumerated());
assertNull(attributeDescriptor.getDefaultValue());
}
Aggregations