Search in sources :

Example 51 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlSchemaTest method testAttributeDescriptor2.

public void testAttributeDescriptor2() 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\" use=\"required\" default=\" 2002 \"/>" + "</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(" 2002 ", attribute.getDefaultValue());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 52 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlSchemaTest method testAny2.

//public void testAny1() throws Exception {
//  XmlDocumentDescriptor documentDescriptor = createDescriptorImpl(
//      "<xsd:schema targetNamespace=\"http://foo\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >" +
//      "  <xsd:element name=\"root\">" +
//      "    <xsd:complexType>" +
//      "      <xsd:sequence minOccurs=\"1\" maxOccurs=\"1\">" +
//      "        <xsd:any namespace=\"##other\" minOccurs=\"0\" maxOccurs=\"unbounded\" processContents=\"skip\"/>" +
//      "      </xsd:sequence>" +
//      "    </xsd:complexType>" +
//      "  </xsd:element>" +
//      "</xsd:schema>"
//  );
//
//  XmlFile xmlFile = (XmlFile)createFile("file.xml",
//      "<root xmlns=\"http://foo\">" +
//      "  <a:a xmlns:a=\"http://bar\" />" +
//      "</root>"
//  );
//
//  XmlElementDescriptor rootDescriptor = documentDescriptor.getElementDescriptor(xmlFile.saveToString().getRootTag());
//  assertNotNull(rootDescriptor);
//
//  XmlTag aTag = xmlFile.saveToString().getRootTag().findSubTag("a:a");
//  assertNotNull(aTag);
//  XmlElementDescriptor aDescriptor = documentDescriptor.getElementDescriptor(aTag);
//  assertNotNull(aDescriptor);
//}
public void testAny2() throws Exception {
    PsiFile dtdFile = createFile("test.xml", "<xsd:schema targetNamespace=\"http://foo\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >" + "  <xsd:element name=\"root\">" + "    <xsd:complexType>" + "      <xsd:sequence minOccurs=\"1\" maxOccurs=\"1\">" + "        <xsd:any namespace=\"##other\" minOccurs=\"0\" maxOccurs=\"unbounded\" processContents=\"skip\"/>" + "      </xsd:sequence>" + "    </xsd:complexType>" + "  </xsd:element>" + "</xsd:schema>");
    XmlNSDescriptor NSDescriptor = new XmlNSDescriptorImpl((XmlFile) dtdFile);
    XmlFile xmlFile = (XmlFile) createFile("file.xml", "<foo:root xmlns:foo=\"http://foo\">" + "  <foo:a xmlns:a=\"http://bar\" />" + "</foo:root>");
    XmlElementDescriptor rootDescriptor = NSDescriptor.getElementDescriptor(xmlFile.getDocument().getRootTag());
    assertNotNull(rootDescriptor);
    XmlTag aTag = xmlFile.getDocument().getRootTag().findFirstSubTag("foo:a");
    assertNotNull(aTag);
//XmlElementDescriptor aDescriptor = NSDescriptor.getElementDescriptor(aTag);
//assertNull(aDescriptor);
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlFile(com.intellij.psi.xml.XmlFile) PsiFile(com.intellij.psi.PsiFile) XmlNSDescriptorImpl(com.intellij.xml.impl.schema.XmlNSDescriptorImpl) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 53 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlSchemaTest method testAttributeDescriptor1.

public void testAttributeDescriptor1() 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: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());
    assertNull(attribute.getDefaultValue());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 54 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlSchemaTest method testAttributeDescriptor4.

public void testAttributeDescriptor4() 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 ref=\"orderDate\" use=\"required\"/>" + "</xsd:complexType>" + "   <xsd:attribute name=\"orderDate\" type=\"xsd:date\" fixed=\"1 01 2001\"/>" + "</xsd:schema>");
    final XmlTag tag = XmlTestUtil.tag("purchaseOrder", getProject());
    XmlElementDescriptor elementDescriptor = NSDescriptor.getElementDescriptor(tag);
    XmlAttributeDescriptor attribute = elementDescriptor.getAttributeDescriptor("orderDate", tag);
    assertNotNull(attribute);
    assertTrue(!attribute.isEnumerated());
    assertTrue(attribute.isFixed());
    assertTrue(attribute.isRequired());
    assertEquals("1 01 2001", attribute.getDefaultValue());
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor) XmlAttributeDescriptor(com.intellij.xml.XmlAttributeDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag)

Example 55 with XmlNSDescriptor

use of com.intellij.xml.XmlNSDescriptor in project intellij-community by JetBrains.

the class XmlSchemaTest method testNamespace3.

public void testNamespace3() throws Exception {
    XmlNSDescriptor NSDescriptor = createDescriptor("<xs:schema xmlns=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + "<xs:element name=\"purchaseOrder\" type=\"PurchaseOrderType\"/>" + "<element name=\"comment\" type=\"xs:string\"/>" + "</xs:schema>");
    assertNotNull(NSDescriptor);
    assertNotNull(NSDescriptor.getElementDescriptor(XmlTestUtil.tag("purchaseOrder", "http://www.w3.org/2001/XMLSchema", getProject())));
    assertNotNull(NSDescriptor.getElementDescriptor(XmlTestUtil.tag("comment", "http://www.w3.org/2001/XMLSchema", getProject())));
    assertNull(NSDescriptor.getElementDescriptor(UNKNOWN_TAG));
}
Also used : XmlNSDescriptor(com.intellij.xml.XmlNSDescriptor)

Aggregations

XmlNSDescriptor (com.intellij.xml.XmlNSDescriptor)87 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)60 XmlTag (com.intellij.psi.xml.XmlTag)52 XmlAttributeDescriptor (com.intellij.xml.XmlAttributeDescriptor)32 XmlFile (com.intellij.psi.xml.XmlFile)21 Nullable (org.jetbrains.annotations.Nullable)11 XmlDocument (com.intellij.psi.xml.XmlDocument)10 PsiElement (com.intellij.psi.PsiElement)5 XmlAttribute (com.intellij.psi.xml.XmlAttribute)5 AnyXmlElementDescriptor (com.intellij.xml.impl.schema.AnyXmlElementDescriptor)5 XmlNSDescriptorImpl (com.intellij.xml.impl.schema.XmlNSDescriptorImpl)5 CachedValue (com.intellij.psi.util.CachedValue)3 NotNull (org.jetbrains.annotations.NotNull)3 FlexMxmlNSDescriptor (com.intellij.javascript.flex.mxml.schema.FlexMxmlNSDescriptor)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 HtmlTag (com.intellij.psi.html.HtmlTag)2 PsiMetaData (com.intellij.psi.meta.PsiMetaData)2 PsiElementProcessor (com.intellij.psi.search.PsiElementProcessor)2 XmlElementDescriptorImpl (com.intellij.xml.impl.schema.XmlElementDescriptorImpl)2