use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlSchemaTest method testElementDescriptor1.
public void testElementDescriptor1() throws Exception {
XmlNSDescriptor NSDescriptor = createDescriptor("<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<xsd:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<xsd:element name=\"comment\" type=\"xsd:string\"/>" + "</xsd:schema>");
XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(XmlTestUtil.tag("purchaseOrder", getProject()));
assertEquals("purchaseOrder", elementDescriptor.getName());
elementDescriptor = NSDescriptor.getElementDescriptor(XmlTestUtil.tag("comment", getProject()));
assertEquals("comment", elementDescriptor.getName());
}
use of com.intellij.xml.XmlNSDescriptor 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.XmlNSDescriptor 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.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlInsightTest method testElementDescriptor1.
public void testElementDescriptor1() throws Exception {
XmlFile file = createFile("<root><a></a><b></b><a></a></root>");
XmlNSDescriptor descriptor = createDescriptor(file);
XmlTag rootTag = file.getDocument().getRootTag();
XmlElementDescriptor element = descriptor.getElementDescriptor(rootTag);
XmlElementDescriptor[] elements = element.getElementsDescriptors(rootTag);
assertEquals(2, elements.length);
assertEquals("a", elements[0].getName());
assertEquals("b", elements[1].getName());
}
use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.
the class XmlInsightTest method testElementDescriptor3.
public void testElementDescriptor3() throws Exception {
XmlFile file = createFile("<root><a><b/><c></c></a><a><c/></a></root>");
XmlNSDescriptor descriptor = createDescriptor(file);
XmlTag rootTag = file.getDocument().getRootTag();
XmlElementDescriptor element = descriptor.getElementDescriptor(rootTag);
element = element.getElementsDescriptors(rootTag)[0];
XmlElementDescriptor[] elements = element.getElementsDescriptors(rootTag.getSubTags()[0]);
assertEquals(2, elements.length);
assertEquals("b", elements[0].getName());
//assertTrue(elements[0].getContentType() == XmlElementDescriptor.CONTENT_TYPE_EMPTY);
assertEquals("c", elements[1].getName());
//assertTrue(elements[1].getContentType() == XmlElementDescriptor.CONTENT_TYPE_CHILDREN);
}
Aggregations