Package org.apache.lenya.xml

Examples of org.apache.lenya.xml.DOMUtil


    /**
     *
     */
    protected void transformXML(Document doc, String childId, short childType, String childName, Map parameters) throws Exception {
        log.error(".transformXML(): " + childId);
        DOMUtil du = new DOMUtil();

        // Replace id
        du.setElementValue(doc, "/echo:entry/echo:id", "tag:bob.blog," + year + ":" + month + ":" + day + ":" + childId);

        // Replace title
        du.setElementValue(doc, "/echo:entry/echo:title", (String)parameters.get("title"));

        // Replace Summary
        du.setElementValue(doc, "/echo:entry/echo:summary", "Summary");

  // Replace link:
        du.setAttributeValue(doc, "/echo:entry/echo:link/@rel""alternate");
        du.setAttributeValue(doc, "/echo:entry/echo:link/@href", "http://bob.blog/");
        du.setAttributeValue(doc, "/echo:entry/echo:link/@type", "text/xml");

        // Replace author
        Identity identity = (Identity)parameters.get("org.apache.lenya.ac.Identity");
        du.setElementValue(doc, "/echo:entry/echo:author/echo:name", identity.getUser().getId());

        // Replace date created (and issued and modified, FIXME: issued should be set during first time publishing, modified should be set during re-publishing)
        DateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        DateFormat ofsfmt = new SimpleDateFormat("Z");

        String dateofs = ofsfmt.format(date);
        String datestr = datefmt.format(date) + dateofs.substring(0, 3) + ":" + dateofs.substring(3, 5);

        du.setElementValue(doc, "/echo:entry/echo:created", datestr);
        du.setElementValue(doc, "/echo:entry/echo:issued", datestr);
        du.setElementValue(doc, "/echo:entry/echo:modified", datestr);
    }
View Full Code Here


     * @param configuration DOCUMENT ME!
     *
     * @throws Exception DOCUMENT ME!
     */
    public void configure(Element root) throws Exception {
        DOMUtil du = new DOMUtil();

        base_url = du.getAttributeValue(root, new XPath("base-url/@href"));
        scope_url = du.getAttributeValue(root, new XPath("scope-url/@href"));
        user_agent = du.getElementValue(root, new XPath("user-agent"));
        uri_list = du.getAttributeValue(root, new XPath("uri-list/@src"));
        htdocs_dump_dir = du.getAttributeValue(root, new XPath("htdocs-dump-dir/@src"));
        if (du.elementExists(root, new XPath("robots"))) {
            robots_file = du.getAttributeValue(root, new XPath("robots/@src"));
            robots_domain = du.getAttributeValue(root, new XPath("robots/@domain"));
        }
    }
View Full Code Here

     * @param configuration DOCUMENT ME!
     *
     * @throws Exception DOCUMENT ME!
     */
    public void configure(Element root) throws Exception {
        DOMUtil du = new DOMUtil();
        update_index_type = du.getAttributeValue(root, new XPath("update-index/@type"));
        index_dir = du.getAttributeValue(root, new XPath("index-dir/@src"));
        htdocs_dump_dir = du.getAttributeValue(root, new XPath("htdocs-dump-dir/@src"));

        String indexerClassName = du.getAttributeValue(root, new XPath("indexer/@class"));
        indexerClass = Class.forName(indexerClassName);
    }
View Full Code Here

            Date start = new Date();

            Indexer indexer = (Indexer) ie.getIndexerClass().newInstance();

            DOMUtil du = new DOMUtil();
            String path = argv[0];
           
            Document config = DocumentHelper.readDocument(new File(path));
            indexer.configure(du.getElement(config.getDocumentElement(), new XPath("indexer")), argv[0]);

            if (argv.length == 2) {
                indexer.indexDocument(new File(argv[1]));
                return;
            }
View Full Code Here

     * Get indexer from configuration
     */
    public static Indexer getIndexer(String luceneConfig) throws Exception {
        IndexConfiguration ie = new IndexConfiguration(luceneConfig);
        Indexer indexer = (Indexer) ie.getIndexerClass().newInstance();
        DOMUtil du = new DOMUtil();
        Document config = DocumentHelper.readDocument(new File(luceneConfig));
        indexer.configure(du.getElement(config.getDocumentElement(), new XPath("indexer")), luceneConfig);

        return indexer;
    }
View Full Code Here

     * @param configuration DOCUMENT ME!
     *
     * @throws Exception DOCUMENT ME!
     */
    public void configure(Element root) throws Exception {
        DOMUtil du = new DOMUtil();

        base_url = du.getAttributeValue(root, new XPath("base-url/@href"));
        scope_url = du.getAttributeValue(root, new XPath("scope-url/@href"));
        user_agent = du.getElementValue(root, new XPath("user-agent"));
        uri_list = du.getAttributeValue(root, new XPath("uri-list/@src"));
        htdocs_dump_dir = du.getAttributeValue(root, new XPath("htdocs-dump-dir/@src"));
        if (du.elementExists(root, new XPath("robots"))) {
            robots_file = du.getAttributeValue(root, new XPath("robots/@src"));
            robots_domain = du.getAttributeValue(root, new XPath("robots/@domain"));
        }
    }
View Full Code Here

    protected void transformXML (Document doc,
         String childId, short childType, String childName,
         Map parameters)
  throws Exception {

        DOMUtil du = new DOMUtil();
        du.setElementValue(doc, "/system/id", childId);
        du.setElementValue(doc, "/system/system_name", childName);
 
        log.debug("system_name = " +
      du.getElementValue(doc.getDocumentElement(),
             new org.apache.lenya.xml.XPath("system_name")));
    }
View Full Code Here

    protected void transformXML (Document doc,
         String childId, short childType, String childName,
         Map parameters)
  throws Exception {

        DOMUtil du = new DOMUtil();
        du.setElementValue(doc, "/system/id", childId);
        du.setElementValue(doc, "/system/system_name", childName);
 
        log.debug("system_name = " +
      du.getElementValue(doc.getDocumentElement(),
             new org.apache.lenya.xml.XPath("system_name")));
    }
View Full Code Here

    /**
     *
     */
    protected void transformXML(Document doc, String childId, short childType, String childName, Map parameters) throws Exception {
        log.error(".transformXML(): " + childId);
        DOMUtil du = new DOMUtil();

        // Replace id
        du.setElementValue(doc, "/echo:entry/echo:id", year + "/" + month + "/" + day + "/" + childId);

        // Replace title
        du.setElementValue(doc, "/echo:entry/echo:title", (String)parameters.get("title"));

        // Replace author
        Identity identity = (Identity)parameters.get("org.apache.lenya.ac.Identity");
        du.setElementValue(doc, "/echo:entry/echo:author/echo:name", identity.getUser().getId());

        // Replace date created (and issued and modified, FIXME: issued should be set during first time publishing, modified should be set during re-publishing)
        DateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        DateFormat ofsfmt = new SimpleDateFormat("Z");

        String dateofs = ofsfmt.format(date);
        String datestr = datefmt.format(date) + dateofs.substring(0, 3) + ":" + dateofs.substring(3, 5);

        du.setElementValue(doc, "/echo:entry/echo:created", datestr);
        du.setElementValue(doc, "/echo:entry/echo:issued", datestr);
        du.setElementValue(doc, "/echo:entry/echo:modified", datestr);
    }
View Full Code Here

            Date start = new Date();

            Indexer indexer = (Indexer) ie.getIndexerClass().newInstance();

            DOMUtil du = new DOMUtil();
            String path = argv[0];
           
            Document config = DocumentHelper.readDocument(new File(path));
            indexer.configure(du.getElement(config.getDocumentElement(), new XPath("indexer")), argv[0]);

            if (argv.length == 2) {
                indexer.indexDocument(new File(argv[1]));
                return;
            }
View Full Code Here

TOP

Related Classes of org.apache.lenya.xml.DOMUtil

Copyright © 2018 www.massapicom. 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.