Package org.jdom.xpath

Examples of org.jdom.xpath.XPath.addNamespace()


  public List<ToolIdentity> createFileIdentities(Document dom, ToolInfo info) {
    List<ToolIdentity> identities = new ArrayList<ToolIdentity>();
    try {
      XPath xpath = XPath.newInstance("//fits:identity");
      Namespace ns = Namespace.getNamespace("fits",Fits.XML_NAMESPACE);
      xpath.addNamespace(ns);
      List<Element> identElements = xpath.selectNodes(dom);
      for(Element element : identElements) {
        Attribute formatAttr = element.getAttribute("format");
        Attribute mimetypeAttr = element.getAttribute("mimetype");
        Element versionElement = element.getChild("version",ns);
View Full Code Here


  }
 
  public FitsMetadataElement getMetadataElement(String name) {
    try {     
      XPath xpath = XPath.newInstance("//fits:"+name);
      xpath.addNamespace("fits",Fits.XML_NAMESPACE);
      Element node = (Element)xpath.selectSingleNode(fitsXml);
      if(node != null) {
        FitsMetadataElement element = buildMetdataIElements(node);
        return element;
      }
View Full Code Here

  @SuppressWarnings("unchecked")
  public List<FitsMetadataElement> getMetadataElements(String name) {
    List<FitsMetadataElement> elements = new ArrayList<FitsMetadataElement>();
    try {
      XPath xpath = XPath.newInstance("//fits:"+name);
      xpath.addNamespace("fits",Fits.XML_NAMESPACE);
      List<Element> nodes = xpath.selectNodes(fitsXml);
      for(Element e : nodes) {
        elements.add(buildMetdataIElements(e));
      }
      return elements;
View Full Code Here

  public List<FitsIdentity> getIdentities() {
    List<FitsIdentity> identities = new ArrayList<FitsIdentity>();
    try {
      XPath xpath = XPath.newInstance("//fits:identity");
      Namespace ns = Namespace.getNamespace("fits",Fits.XML_NAMESPACE);
      xpath.addNamespace(ns);
      List<Element> identElements = xpath.selectNodes(fitsXml);
      for(Element element : identElements) {
        FitsIdentity fileIdentSect = new FitsIdentity();
       
        //get the identity attributes
View Full Code Here

      Document dom = result.getFitsXml();
      try {
        //only look at non null dom structures
        if(dom != null) {
          XPath xpath = XPath.newInstance(xpath_query);
          xpath.addNamespace("fits",Fits.XML_NAMESPACE);
          Element e = (Element)xpath.selectSingleNode(dom);
          if(e != null && e.getChildren().size() > 0) {
            if(useChildren) {
              e = (Element)e.getChildren().get(0);
            }
View Full Code Here

        continue;
      }
      ToolInfo toolInfo = result.getTool().getToolInfo();
      try {
        XPath xpath = XPath.newInstance("//fits:"+element.getName());
        xpath.addNamespace("fits",Fits.XML_NAMESPACE);
        Element e = (Element)xpath.selectSingleNode(dom);
        if(e != null) {
          e.setAttribute("toolname",toolInfo.getName());
          e.setAttribute("toolversion",toolInfo.getVersion());
          fitsElements.add(e);
View Full Code Here

        // Get all constraints that have our URL pattern
        // (Note the crazy j: prefix to denote the 2.4 j2ee schema)
        selector = "//j:web-app/j:security-constraint[j:web-resource-collection/j:url-pattern=\"" + url + "\"]";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> constraints = xpath.selectNodes( root );

        // Get all constraints that match our Role pattern
        selector = "//j:web-app/j:security-constraint[j:auth-constraint/j:role-name=\"" + role.getName() + "\"]";
        xpath = XPath.newInstance( selector );
View Full Code Here

        List<?> constraints = xpath.selectNodes( root );

        // Get all constraints that match our Role pattern
        selector = "//j:web-app/j:security-constraint[j:auth-constraint/j:role-name=\"" + role.getName() + "\"]";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> roles = xpath.selectNodes( root );

        // If we can't find either one, we must not be constrained
        if ( constraints.size() == 0 )
        {
View Full Code Here

        Element root = webxml.getRootElement();

        // Get roles referred to by constraints
        String selector = "//j:web-app/j:security-constraint/j:auth-constraint/j:role-name";
        XPath xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> nodes = xpath.selectNodes( root );
        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
        {
            String role = ( (Element) it.next() ).getTextTrim();
            roles.add( new Role( role ) );
View Full Code Here

        }

        // Get all defined roles
        selector = "//j:web-app/j:security-role/j:role-name";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        nodes = xpath.selectNodes( root );
        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
        {
            String role = ( (Element) it.next() ).getTextTrim();
            roles.add( new Role( role ) );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.