⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tldtodocbook.java

📁 分页查询控件 分页查询控件
💻 JAVA
字号:
package org.extremecomponents.util;import java.io.File;import java.io.IOException;import java.util.Iterator;import java.util.List;import org.apache.commons.io.FileUtils;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.Task;import org.jdom.Document;import org.jdom.Element;import org.jdom.JDOMException;import org.jdom.input.SAXBuilder;import org.jdom.xpath.XPath;/** * Write a tld file to the docbook standard. Class really needs to be * reworked in a big way. This is very much a work in progress. *  * @author Jeff Johnston */public class TldToDocbook extends Task {    private String destdir;    public void setDestdir(String destdir) {        this.destdir = destdir;    }    private String getXML()            throws JDOMException, IOException {        StringBuffer sb = new StringBuffer();        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");        sb.append("<chapter>\n");        sb.append("<title>Tag Attributes</title>\n");        File fileObj = new File("/home/jeff/workspace/eXtremeComponents/resources/extremecomponents.tld");        SAXBuilder builder = new SAXBuilder();        Document doc = builder.build(fileObj);        XPath xpath = XPath.newInstance("/taglib/tag");        List records = xpath.selectNodes(doc);        for (Iterator iter = records.iterator(); iter.hasNext();) {            Element tag = (Element) iter.next();//            Element tagName = tag.getChild("name");//            Element tagClass = tag.getChild("tag-class");//            Element bodyContent = tag.getChild("body-content");            Element displayName = tag.getChild("display-name");//            Element tagDescription = tag.getChild("description");            startTable(sb, displayName.getValue());            List attributes = tag.getChildren("attribute");            for (Iterator iterator = attributes.iterator(); iterator.hasNext();) {                sb.append("\t\t\t<row>\n");                Element attribute = (Element) iterator.next();                Element name = attribute.getChild("name");//                Element required = attribute.getChild("required");                Element description = attribute.getChild("description");                sb.append("\t\t\t\t<entry><literal>" + name.getValue() + "</literal></entry>\n");                sb.append("\t\t\t\t<entry><literal>" + description.getValue() + "</literal></entry>\n");                sb.append("\t\t\t</row>\n");            }            endTable(sb);        }        sb.append("</chapter>\n");        return sb.toString();    }    public void startTable(StringBuffer sb, String name) {        sb.append("<section>\n");        sb.append("<title>" + name + "</title>\n");        sb.append("<para><table>\n");        sb.append("\t<title></title>\n");        sb.append("\t<tgroup cols=\"2\">\n");        sb.append("<colspec colname=\"c1\" colwidth=\"1*\"/>\n");        sb.append("<colspec colname=\"c2\" colwidth=\"3*\"/>	\n");        sb.append("\t\t<thead>\n");        sb.append("\t\t\t<row>\n");        sb.append("\t\t\t<entry>Name</entry>\n");        sb.append("\t\t\t<entry>Description</entry>\n");        sb.append("\t\t\t</row>\n");        sb.append("\t\t</thead>\n");        sb.append("\t\t<tbody>\n");    }    public void endTable(StringBuffer sb) {        sb.append("\t\t</tbody>\n");        sb.append("\t</tgroup>\n");        sb.append("</table></para>\n");        sb.append("</section>\n");    }    public void execute()            throws BuildException {        log("TldToDocbook - Start");        try {            TldToDocbook docbook = new TldToDocbook();            String xml = docbook.getXML();            File file = new File(destdir);            FileUtils.writeStringToFile(file, xml, null);        } catch (Exception e) {            e.printStackTrace();        }        log("TldToDocbook - End");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -