Examples of JDOMXPath


Examples of org.jaxen.jdom.JDOMXPath

    FilterInputStream fis = new FilterInputStream(zis) {
      public void close() {};
    };
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(fis);
    XPath path = new JDOMXPath("/office:document-meta/office:meta/*");
    Element root = doc.getRootElement();
    path.addNamespace("office", root.getNamespace("office").getURI());
    List list = path.selectNodes(doc);
    for (int i = 0; i < list.size(); i++) {
      Element n = (Element)list.get(i);
      String text = n.getText();
      if (text.trim().equals("")) continue;
      String name = n.getName();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

   */
  public Collection<CCLicense> getLicenses(String language) {

    // create XPath expressions
    try {
      JDOMXPath xp_Licenses = new JDOMXPath("//licenses/license");
      JDOMXPath xp_LicenseID = new JDOMXPath("@id");
      URL classUrl = new URL(this.cc_root + "/?locale=" + language);
      Document classDoc = this.parser.build(classUrl);
      // extract the identifiers and labels using XPath
      List<Element> results = xp_Licenses.selectNodes(classDoc);
      // populate licenses container
      this.licenses.clear();
      for (int i = 0; i < results.size(); i++) {
        Element license = results.get(i);
        // add if not filtered
        String liD = ((Attribute)xp_LicenseID.selectSingleNode(license)).getValue();
        if (! lcFilter.contains(liD)) {
          this.licenses.add(new CCLicense(liD, license.getText(), i));
        }
      }
    } catch (JaxenException jaxen_e) {
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

   * @see CCLicense
   *
   */
  public Collection<CCLicenseField> getLicenseFields(String license, String language) {

    JDOMXPath xp_LicenseField;
    JDOMXPath xp_LicenseID;
    JDOMXPath xp_FieldType;
    JDOMXPath xp_Description;
    JDOMXPath xp_Label;
    JDOMXPath xp_Enum;

    Document fieldDoc;

    URL classUrl;
    List results = null;
    List enumOptions = null;

    // create XPath expressions
    try {
      xp_LicenseField = new JDOMXPath("//field");
      xp_LicenseID = new JDOMXPath("@id");
      xp_Description = new JDOMXPath("description");
      xp_Label = new JDOMXPath("label");
      xp_FieldType = new JDOMXPath("type");
      xp_Enum = new JDOMXPath("enum");

    } catch (JaxenException e) {
      return null;
    }

    // retrieve and parse the license class document
    try {
      classUrl = new URL(this.cc_root + "/license/" + license + "?locale=" + language);
    } catch (Exception err) {
      // do nothing... but we should
      return null;
    }

    // parse the licenses document
    try {
      fieldDoc = this.parser.build(classUrl);
    } catch (JDOMException e) {
      return null;
    } catch (IOException e) {
      return null;
    }

    // reset the field definition container
    this.licenseFields.clear();

    // extract the identifiers and labels using XPath
    try {
      results = xp_LicenseField.selectNodes(fieldDoc);
    } catch (JaxenException e) {
      return null;
    }

    for (int i=0; i < results.size(); i++) {
      Element field = (Element)results.get(i);

      try {
        // create the field object
        CCLicenseField cclicensefield = new CCLicenseField(((Attribute)xp_LicenseID.selectSingleNode(field)).getValue(),
            ((Element)xp_Label.selectSingleNode(field)).getText() );

        // extract additional properties
        cclicensefield.setDescription( ((Element)xp_Description.selectSingleNode(field)).getText() );
        cclicensefield.setType( ((Element)xp_FieldType.selectSingleNode(field)).getText() );

        enumOptions = xp_Enum.selectNodes(field);

        for (int j = 0; j < enumOptions.size(); j++) {
          String id = ((Attribute)xp_LicenseID.selectSingleNode(enumOptions.get(j))).getValue();
          String label =((Element)xp_Label.selectSingleNode(enumOptions.get(j))).getText();

View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

   * @return A String containing the URI for the license issued.
   */
  public String getLicenseUrl() {
    String text = null;
    try {
      JDOMXPath xp_LicenseName = new JDOMXPath("//result/license-uri");
        text =  ((Element)xp_LicenseName.selectSingleNode(this.license_doc)).getText();
    }
    catch (Exception e) {
      log.warn(e.getMessage());
      setSuccess(false);
      text = "An error occurred getting the license - uri.";
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

   * @return A String containing the license name.
   */
  public String getLicenseName() {
    String text = null;
    try {
      JDOMXPath xp_LicenseName = new JDOMXPath("//result/license-name");
      text =  ((Element)xp_LicenseName.selectSingleNode(this.license_doc)).getText();
    }
    catch (Exception e) {
      log.warn(e.getMessage());
      setSuccess(false);
      text = "An error occurred on the license name.";
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

    throws IOException {
    String myString = null;
    java.io.ByteArrayOutputStream outputstream = new java.io.ByteArrayOutputStream();
    try {
      outputstream.write("<result>\n".getBytes());
      JDOMXPath xpathRdf         = new JDOMXPath("//result/rdf");
      JDOMXPath xpathLicenseRdf         = new JDOMXPath("//result/licenserdf");
      XMLOutputter xmloutputter   = new XMLOutputter();
      Element rdfParent             = ((Element)xpathRdf.selectSingleNode(this.license_doc));
      xmloutputter.output(rdfParent, outputstream);
      Element licenseRdfParent       = ((Element)xpathLicenseRdf.selectSingleNode(this.license_doc));
      outputstream.write("\n".getBytes());
      xmloutputter.output(licenseRdfParent, outputstream);
      outputstream.write("\n</result>\n".getBytes());
    } catch (Exception e) {
      log.warn("An error occurred getting the rdf . . ." + e.getMessage() );
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

  }

  public boolean isSuccess() {
    setSuccess(false);
    java.io.ByteArrayOutputStream outputstream = new java.io.ByteArrayOutputStream();
    JDOMXPath xp_Success = null;
    String text = null;
    try {
      xp_Success = new JDOMXPath("//message");
      text =  ((Element)xp_Success.selectSingleNode(this.license_doc)).getText();
      setErrorMessage(text);
    }
    catch (Exception e) {
      log.warn("There was an issue . . . " + text);
      setSuccess(true);
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        try {
            SAXBuilder builder = new SAXBuilder();
            Document d = builder.build( in );          

            Namespace ns = Namespace.getNamespace( "planets", "http://www.planets-project.eu/xml/ns/planets/core/mimetypes" );           
            JDOMXPath xpath = new JDOMXPath("/planets:Document/planets:MIME-mapping");   
            xpath.addNamespace( "planets", "http://www.planets-project.eu/xml/ns/planets/core/mimetypes" );                       
           
            Iterator<?> _mappings = xpath.selectNodes( d ).iterator();
            while ( _mappings.hasNext() ) {           
           
                Element _mapping = (Element)_mappings.next();
                String _extname = ((Element)_mapping.getChild("Extension", ns)).getText().toLowerCase();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        try {
            SAXBuilder builder = new SAXBuilder();
            Document d = builder.build( in );          

            Namespace ns = Namespace.getNamespace( "planets", "http://www.planets-project.eu/xml/ns/planets/core/mimetypes" );           
            JDOMXPath xpath = new JDOMXPath("/planets:Document/planets:MIME-mapping");   
            xpath.addNamespace( "planets", "http://www.planets-project.eu/xml/ns/planets/core/mimetypes" );                       
           
            Iterator<?> _mappings = xpath.selectNodes( d ).iterator();
            while ( _mappings.hasNext() ) {           
           
                Element _mapping = (Element)_mappings.next();
                String _extname = ((Element)_mapping.getChild("Extension", ns)).getText().toLowerCase();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        }
       
        Element root = doc.getRootElement();
       
        try {
            JDOMXPath endpointXPath = new JDOMXPath("services/service[@id='migrate1']/endpoint");
           
            Element endpoint = (Element)endpointXPath.selectSingleNode(root);
           
            endpoint.setText(wsdlLocation);
           
            String settings = selectedPlan.getRecommendation().getAlternative().getExperiment().getSettings();
           
            if (settings == null) {
                settings = "";
            }
           
            Scanner scanner = new Scanner(settings);
           
            JDOMXPath migrateServiceXPath = new JDOMXPath("services/service[@id='migrate1']");
           
            Element migrateService = (Element)migrateServiceXPath.selectSingleNode(root);
           
            migrateService.setContent(endpoint);
           
            Element parameters = new Element ("parameters");
           
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.