use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor3.
public void testElementDescriptor3() 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:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(3, elements.length);
assertEquals("shipTo", elements[0].getName());
assertEquals("billTo", elements[1].getName());
assertEquals("items", elements[2].getName());
assertEquals("shipTo", elementDescriptor.getElementDescriptor(SHIP_TO, null).getName());
assertNull(elementDescriptor.getElementDescriptor(UNKNOWN_TAG, null));
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testAttributeDescriptor3.
public void testAttributeDescriptor3() 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:attribute name=\"orderDate\" type=\"xsd:date\" fixed=\"1 01 2001\"/>" + "</xsd:complexType>" + "</xsd:schema>");
final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor attribute = elementDescriptor.getAttributeDescriptor("orderDate", tag);
assertTrue(!attribute.isEnumerated());
assertTrue(attribute.isFixed());
assertTrue(!attribute.isRequired());
assertEquals("1 01 2001", attribute.getDefaultValue());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor7.
public void testElementDescriptor7() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\">" + "<xsd:complexType name=\"PurchaseOrderType\">" + " <xsd:sequence>" + " <xsd:element name=\"shipTo\">" + " <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:element>" + " </xsd:sequence>" + "</xsd:complexType>" + "</xsd:element>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
assertEquals(0, attributes.length);
XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(1, elements.length);
assertEquals("shipTo", elements[0].getName());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor13.
public void testElementDescriptor13() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\">" + "<xsd:complexType name=\"PurchaseOrderType\">" + " <xsd:sequence>" + " <xsd:element ref=\"shipTo\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "</xsd:element>" + "<xsd:element name=\"shipTo\" abstract=\"true\">" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
final XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(0, elements.length);
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testNamespace1.
public void testNamespace1() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + "<xs:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xs:element name=\"comment\" type=\"xs:string\"/>" + "</xs:schema>");
assertNotNull(NSDescriptor);
assertNotNull(NSDescriptor.getElementDescriptor(XmlTestUtil.tag("purchaseOrder", getProject())));
assertNotNull(NSDescriptor.getElementDescriptor(XmlTestUtil.tag("comment", getProject())));
assertNull(NSDescriptor.getElementDescriptor(UNKNOWN_TAG));
}
Aggregations