use of com.intellij.xml.XmlElementDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor11.
public void testElementDescriptor11() 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:element name=\"shipTo2\" type=\"USAddress\"/>" + " <xsd:element name=\"items\" type=\"Items\"/>" + " </xsd:restriction>" + " </xsd:complexContent>" + "</xsd:complexType>" + "<xsd:complexType name=\"PurchaseOrderType2\">" + " <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(4, elements.length);
assertEquals("shipTo", elements[0].getName());
assertEquals("billTo", elements[1].getName());
assertEquals("shipTo2", elements[2].getName());
assertEquals("items", elements[3].getName());
}
use of com.intellij.xml.XmlElementDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor4.
public void testElementDescriptor4() 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\"/>" + " <xsd:attribute name=\"name\" type=\"xsd:string\"/>" + "</xsd:complexType>" + "</xsd:schema>");
final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlAttributeDescriptor[] attributes = elementDescriptor.getAttributesDescriptors(tag);
assertEquals(2, attributes.length);
assertEquals("orderDate", attributes[0].getName());
assertEquals("name", attributes[1].getName());
assertEquals("name", elementDescriptor.getAttributeDescriptor("name", tag).getName());
assertNull(elementDescriptor.getAttributeDescriptor("xxx", tag));
}
use of com.intellij.xml.XmlElementDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testNamespace2.
public void testNamespace2() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema targetNamespace=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:complexType name=\"PurchaseOrderType\">" + " <xsd:sequence>" + " <xsd:element ref=\"xsd:items\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "<xsd:element name=\"items\" type=\"xsd:string\"/>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", "http://www.w3.org/2001/XMLSchema", getProject());
XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl) NSDescriptor.getElementDescriptor(tag);
XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(1, elements.length);
assertEquals("items", elements[0].getName());
assertEquals("items", elementDescriptor.getElementDescriptor("items").getName());
assertNull(elementDescriptor.getElementDescriptor("xxx"));
}
use of com.intellij.xml.XmlElementDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor14.
public void testElementDescriptor14() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema targetNamespace=\"http://www.deansoft.com/AddressBook\" xmlns:ab=\"http://www.deansoft.com/AddressBook\" 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:complexType name=\"USAddress\">" + " <xsd:attribute name=\"orderDate\" type=\"xsd:date\"/>" + " <xsd:element name=\"items\" type=\"Items\"/>" + " </xsd:complexType>" + "</xsd:element>" + "<xsd:element name=\"name\" substitutionGroup=\"ab:shipTo\"/>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", "http://www.deansoft.com/AddressBook", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
final XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(1, elements.length);
assertEquals("name", elements[0].getName());
XmlAttributeDescriptor[] attrs = elements[0].getAttributesDescriptors(tag);
assertEquals(1, attrs.length);
assertEquals("orderDate", attrs[0].getName());
XmlElementDescriptor[] element0Descriptors = elements[0].getElementsDescriptors(tag.findFirstSubTag(elements[0].getName()));
assertEquals(1, element0Descriptors.length);
assertEquals("items", element0Descriptors[0].getName());
}
use of com.intellij.xml.XmlElementDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor8.
public void testElementDescriptor8() 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 ref=\"items\"/>" + " </xsd:sequence>" + "</xsd:complexType>" + "<xsd:element name=\"items\" type=\"xsd:string\"/>" + "</xsd:schema>");
XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
XmlElementDescriptor[] elements = elementDescriptor.getElementsDescriptors(tag);
assertEquals(1, elements.length);
assertEquals("items", elements[0].getName());
assertEquals("items", elementDescriptor.getElementDescriptor(XmlTestUtil.tag("items", getProject()), null).getName());
assertNull(elementDescriptor.getElementDescriptor(UNKNOWN_TAG, null));
}
Aggregations