2009年10月

   
渐来的季节让我在天还蒙蒙亮时就要从被窝中爬起。那种纠结更是让我每次都在似乎咬牙一般的坚持着。而前方的路更是比此时的天,更加昏暗。

   
这个时候的北京已然没有了头些天的那种‘晴朗’,取而代之的是‘不适宜常时间户外活动’的糟糕天气。上班已然和外界隔绝。那里只有一群对梦想渴望的激情在燃烧的年轻人们。

 

   
漫步穿过那些让很多很多人梦寐以求的‘大公司’。Lenovo,东软,神州,Hisoft,百度,Oracle,venceinfo等等的好多的大公司,而我即将走入的就是有几个‘国家软件出口基地’大字的地方。早晨人很多,但见到的不多,那是因为很多人坐着公司的班车直接到公司门口,而我在挎着包,嘴里吃着马路边的鸡蛋饼子,(为了不让自己‘受苦’,我还让加了个火腿。)

 

   
走进办公大楼,那里很正式,有保安、保洁的。厕所里还有洗手液和手纸。而这些似乎在这里不算是什么。办公桌的旁边有我的名字。看着自己的名字,似乎让我感觉在做梦一般,忽然想想我就在这了。呵呵,抬起头,好好coding吧,就这样算是找到了我的临时落脚点了。

    
知道了自己有多差,而我不想自己会是公司招人的一大败笔,我要抓紧时间,适应这的一切,从0开始,追求自己的梦想。

    
感谢这些多天来他们的安慰和支持,很感谢他们,他们知道我的心,谢谢!

    
早起和路上花的这些时间都不是什么,而在你手底下出来的东西才是证明你的一切的最有力的things。严格要求自己,让自己让公司都为自己高兴,至少不要让这个公司失望!

 

 

   
电影院归来。理解了为什么电影名要译为《就是这样》,确实,“就是这样”,只有MJ可以用这样简单朴素的一句话,来概括自己的演出,乃至一生。请不要称MJ为艺术家了,请直接称他为“艺术”——因为有太多“艺术家”了。而真的艺术,只有看了这部电影版的演唱会,你才能领略。同时,还有一个伟大的灵魂。

   我再次怀疑MJ的死因。看他排练时的身体状况,他健康强壮的如同那些年轻的全世界最好的舞蹈演员,怎么能就这样没了?美国不能告诉我们就这样MJ没了,我们需要一个答案。这不会比抓住本-拉登还难吧?

  电影的剪辑一定是尊重了MJ的一贯宗旨和意愿:给人们传递爱和快乐。所以,刻意地避免了很多煽情的素材,甚至是有意把观众的眼泪掬在眼眶就是不让你流下来。这样哭不出来的感觉,散场之后才更加难受。我羡慕那些可以边看电影边流泪的人,不分男女,前后左右都有人在啜泣。

  请全国的电影院不要急着开灯,请观众不要急着离开,一定要静静地,看完最后一个画面,听完最后一首歌。因为,无论人们怎么鼓掌、欢呼、哭泣,那个人都不会再返场了。所以,别那么着急,这已经是最后的演出了。你就算看一百次,也是最后的演出。

  提醒一下准备看《就是这样》这部电影的朋友,最好在去影院之前一小时不喝少喝水,电影开始后也要少喝,因为假如电影中途你膀胱的括约肌不那么争气的话,你会痛恨自己的——因为你绝不想错过每一秒钟。

   我注意到今晚看电影的女士们很多都穿的很隆重,大家是带着一种送别的心情去看MJ的。电影结束后有一多半的人一直不愿起身,直到最后一幅字幕在银幕上消失,最后一个音符从空中飘过。我听到一片叹息。有人说:真的就这样结束了?

   我忽然觉得中国艺术某些领域与MJ的差距,比中国足球与巴西队的差距相比,还要大很多倍。因为2003年非典爆发前,2002世界杯冠军巴西队在广州与中国队的比赛,假打之下中国队还能蒙个平局;可是我们很多一线歌手的假唱,都比不上MJ排练时的随意挥洒之万一,甚至远远不及给他伴唱的任何一个无名歌手。

   
所以,这部电影从某种角度来说绝对可以提高我国人民的艺术欣赏水平和鉴赏力。有什么观众就有什么演员,有什么观众才有什么演员。

   耶稣是被人钉在十字架上死的;MJ也是被人类的嫉妒和阴暗杀死的。或者说,他完成了自己的地球苦旅,回到天国去了,成仙成佛了。与他带给人类的快乐和爱相比,人们给了他什么?财富?这是嫉妒的原因吧。难道他的财富不比任何一个政客的干净一万倍?难道不是他该得的?

   有些容易哭的人,记得带好纸巾去电影院。记得不要迟到,不要早退,不要打开手机铃声最好关掉手机。还有给影院的一个建议,音乐声是否可以再大一点儿?这比给观众发一根荧光棒来的更好。谢谢。

   最后由衷地谢谢有关部门,在第一时间让我们与全球同步,看到了MJ最后的身影。

   
虽然憋着很难受,因为我不是一个容易流泪的人。假如电影里让那些舞蹈演员们哭出来,或者在最后有一些MJ身后的全球悼念的镜头,来催一下泪,不要让我这样的人一直卡在中间不上不下,也许更好。但愿不是被剪辑掉了。如果是被剪掉的话,我收回对有关部门的感谢,我要说:XXX!你们是不是人造的?

   
当然,我也愿意相信这样的调子是MJ的心愿。

    我接受这电影,虽然我此时依然不能接受他的离开。

This is the official website for SAX. It replaces David Megginson's original SAX page.

SAX is the Simple API for XML, originally a Java-only API. SAX was the first widely adopted API for XML in Java, and is a “de facto” standard. The current version is SAX 2.0.1, and there are versions for several programming language environments other than Java.

SAX has recently switched over to the SourceForge project infrastructure. The intent is to continue the open development and maintainence process for SAX (no NDAs required) while making it easier to track open SAX issues outside of the high-volume xml-dev list. Project resources include archived mailing lists and a download area. See the Project Page link for full information about project facilities which are being used, as well as news announcements. Use the sax-users@lists.sourceforge.net mailing list to discuss problems that come up when you're trying to use SAX.

David Megginson, who runs an XML consulting company, has resumed maintaining SAX after a period of excellent work by David Brownell (if you use SAX, you should think about buying David Brownell's SAX2 book).

27-April 2004: SAX 2.0.2 (sax2 r3) is out. Download it by going to the Sourceforge download area. That download includes full source, pre-generated javadoc, and a JAR file you can install.

29-January 2002: SAX 2.0.1 (sax2 r2) is out! Download it by going to the Sourceforge download area. That download includes full source, pre-generated javadoc, and a JAR file you can install. Or, consult the javadoc link at left. That's current, and includes the preliminary "SAX2 Extensions 1.1" APIs.

12-November 2001: There are some SAX2 conformance tests available, using the JUNIT testing framework. Download the "sax2unit" tests at the xmlconf project. These are in addition to the SAX2-hosted XML conformance tests mentioned on the "links" page, and address different issues.

许海潮的专栏
 
XML现在已经成为一种通用的数据交换格式,它的平台无关性,语言无关性,系统无关性,给数据集成与交互带来了极大的方便。对于XML本身的语法知识与技术细节,需要阅读相关的技术文献,这里面包括的内容有DOM(Document
Object Model),DTD(Document Type Definition),SAX(Simple API for
XML),XSD(Xml Schema Definition),XSLT(Extensible Stylesheet Language
Transformations),具体可参阅w3c官方网站文档http://www.w3.org获取更多信息。

       
XML在不同的语言里解析方式都是一样的,只不过实现的语法不同而已。基本的解析方式有两种,一种叫SAX,另一种叫DOM。SAX是基于事件流的解析,DOM是基于XML文档树结构的解析。假设我们XML的内容和结构如下:

encoding=”UTF-8″?>

 
    ddviplinux
    m
    30
 

本文使用JAVA语言来实现DOM与SAX的XML文档生成与解析。

首先定义一个操作XML文档的接口XmlDocument 它定义了XML文档的建立与解析的接口。

package com.alisoft.facepay.framework.bean;

 

public interface XmlDocument {

 

public void createXml(String fileName);

 

public void parserXml(String fileName);

}

1. DOM生成和解析XML文档

       
为 XML 文档的已解析版本定义了一组接口。解析器读入整个文档,然后构建一个驻留内存的树结构,然后代码就可以使用 DOM
接口来操作这个树结构。优点:整个文档树在内存中,便于操作;支持删除、修改、重新排列等多种功能;缺点:将整个文档调入内存(包括无用的节点),浪费时间和空间;使用场合:一旦解析了文档还需多次访问这些数据;硬件资源充足(内存、CPU)。

package com.alisoft.facepay.framework.bean;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.PrintWriter;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.parsers.ParserConfigurationException;

import javax.xml.transform.OutputKeys;

import javax.xml.transform.Transformer;

import
javax.xml.transform.TransformerConfigurationException;

import javax.xml.transform.TransformerException;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.dom.DOMSource;

import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

import org.xml.sax.SAXException;

 

public class DomDemo implements XmlDocument {

   

    private
Document document;

 

    private
String fileName;

 

    public
void init() {

      
try {

          
DocumentBuilderFactory factory = DocumentBuilderFactory

                 
.newInstance();

          
DocumentBuilder builder = factory.newDocumentBuilder();

          
this.document = builder.newDocument();

      
} catch (ParserConfigurationException e) {

          
System.out.println(e.getMessage());

      
}

    }

 

    public
void createXml(String fileName) {

 

      
Element root = this.document.createElement_x(“employees”);

      
this.document.appendChild(root);

      
Element employee = this.document.createElement_x(“employee”);

      
Element name = this.document.createElement_x(“name”);

      
name.appendChild(this.document.createTextNode(“丁宏亮“));

      
employee.appendChild(name);

      
Element sex = this.document.createElement_x(“sex”);

      
sex.appendChild(this.document.createTextNode(“m”));

      
employee.appendChild(sex);

      
Element age = this.document.createElement_x(“age”);

      
age.appendChild(this.document.createTextNode(“30″));

      
employee.appendChild(age);

      
root.appendChild(employee);

 

      
TransformerFactory tf = TransformerFactory.newInstance();

      
try {

          
Transformer transformer = tf.newTransformer();

          
DOMSource source = new DOMSource(document);

          
transformer.setOutputProperty(OutputKeys.ENCODING, “gb2312″);

          
transformer.setOutputProperty(OutputKeys.INDENT, “yes”);

          
PrintWriter pw = new PrintWriter(new
FileOutputStream(fileName));

          
StreamResult result = new StreamResult(pw);

          
transformer.transform(source, result);

          
System.out.println(“生成XML文件成功!”);

      
} catch (TransformerConfigurationException e) {

 

          
System.out.println(e.getMessage());

      
} catch (IllegalArgumentException e) {

 

          
System.out.println(e.getMessage());

      
} catch (FileNotFoundException e) {

 

          
System.out.println(e.getMessage());

      
} catch (TransformerException e) {

 

          
System.out.println(e.getMessage());

      
}

 

    }

 

    public
void parserXml(String fileName) {

      
try {

          
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();

          
DocumentBuilder db = dbf.newDocumentBuilder();

          
Document document = db.parse(fileName);

          
NodeList employees = document.getChildNodes();

          
for (int i = 0; i < employees.getLength(); i++)
{

             
Node employee = employees.item(i);

             
NodeList employeeInfo = employee.getChildNodes();

             
for (int j = 0; j < employeeInfo.getLength(); j++)
{

                 
Node node = employeeInfo.item(j);

                 
NodeList employeeMeta = node.getChildNodes();

                 
for (int k = 0; k < employeeMeta.getLength(); k++)
{

                    
System.out.println(employeeMeta.item(k).getNodeName()

                           
+ “:” + employeeMeta.item(k).getTextdescription());

                 
}

             
}

          
}

          
System.out.println(“解析完毕“);

      
} catch (FileNotFoundException e) {

          
System.out.println(e.getMessage());

      
} catch (ParserConfigurationException e) {

          
System.out.println(e.getMessage());

      
} catch (SAXException e) {

          
System.out.println(e.getMessage());

      
} catch (IOException e) {

          
System.out.println(e.getMessage());

      
}

    
}

}

2. SAX生成和解析XML文档

       
为解决DOM的问题,出现了SAX。SAX
,事件驱动。当解析器发现元素开始、元素结束、文本、文档的开始或结束等时,发送事件,程序员编写响应这些事件的代码,保存数据。优点:不用事先调入整个文档,占用资源少;SAX解析器代码比DOM解析器代码小,适于Applet,下载。缺点:不是持久的;事件过后,若没保存数据,那么数据就丢了;无状态性;从事件中只能得到文本,但不知该文本属于哪个元素;使用场合:Applet;只需XML文档的少量内容,很少回头访问;机器内存少;

package com.alisoft.facepay.framework.bean;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.InputStream;

import javax.xml.parsers.ParserConfigurationException;

import javax.xml.parsers.SAXParser;

import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;

import org.xml.sax.SAXException;

import org.xml.sax.helpers.DefaultHandler;

 

public class SaxDemo implements XmlDocument {

 

    public
void createXml(String fileName) {

       
System.out.println(“<<”+filename+“>>”);

    }

 

    public
void parserXml(String fileName) {

      
SAXParserFactory saxfac = SAXParserFactory.newInstance();

 

      
try {

 

          
SAXParser saxparser = saxfac.newSAXParser();

 

          
InputStream is = new FileInputStream(fileName);

 

          
saxparser.parse(is, new MySAXHandler());

 

      
} catch (ParserConfigurationException e) {

 

          
e.printStackTrace();

 

      
} catch (SAXException e) {

 

          
e.printStackTrace();

 

      
} catch (FileNotFoundException e) {

 

          
e.printStackTrace();

 

      
} catch (IOException e) {

 

          
e.printStackTrace();

 

      
}

 

    }

 

}

 

class MySAXHandler extends DefaultHandler {

 

    boolean
hasAttribute = false;

 

   
Attributes attributes = null;

 

    public
void startDocument() throws SAXException {

 

      
System.out.println(“文档开始打印了“);

 

    }

 

    public
void endDocument() throws SAXException {

 

      
System.out.println(“文档打印结束了“);

 

    }

 

    public
void startElement(String uri, String localName, String qName,

 

   
Attributes attributes) throws SAXException {

 

      
if (qName.equals(“employees”)) {

 

          
return;

 

      
}

 

      
if (qName.equals(“employee”)) {

 

          
System.out.println(qName);

 

      
}

 

      
if (attributes.getLength() > 0) {

 

          
this.attributes = attributes;

 

          
this.hasAttribute = true;

 

      
}

 

    }

 

    public
void endElement(String uri, String localName, String qName)

 

    throws
SAXException {

 

      
if (hasAttribute && (attributes !=
null)) {

 

          
for (int i = 0; i < attributes.getLength(); i++)
{

 

             
System.out.println(attributes.getQName(0)

                    
+ attributes.getValue(0));

 

          
}

 

      
}

 

    }

 

    public
void characters(char[] ch, int start, int length)

 

    throws
SAXException {

 

      
System.out.println(new String(ch, start, length));

 

    }

 

}

3. DOM4J生成和解析XML文档

        
DOM4J 是一个非常非常优秀的Java XML
API,具有性能优异、功能强大和极端易用使用的特点,同时它也是一个开放源代码的软件。如今你可以看到越来越多的 Java 软件都在使用
DOM4J 来读写 XML,特别值得一提的是连 Sun 的 JAXM 也在用 DOM4J。

package com.alisoft.facepay.framework.bean;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.io.Writer;

import java.util.Iterator;

import org.dom4j.Document;

import org.dom4j.DocumentException;

import org.dom4j.DocumentHelper;

import org.dom4j.Element;

import org.dom4j.io.SAXReader;

import org.dom4j.io.XMLWriter;

 

public class Dom4jDemo implements XmlDocument {

 

    public
void createXml(String fileName) {

      
Document document = DocumentHelper.createDocument();

      
Element employees=document.addElement(“employees”);

      
Element employee=employees.addElement(“employee”);

      
Element name= employee.addElement(“name”);

      
name.setText(“ddvip”);

      
Element sex=employee.addElement(“sex”);

      
sex.setText(“m”);

      
Element age=employee.addElement(“age”);

      
age.setText(“29″);

      
try {

          
Writer fileWriter=new FileWriter(fileName);

          
XMLWriter xmlWriter=new XMLWriter(fileWriter);

          
xmlWriter.write(document);

          
xmlWriter.close();

      
} catch (IOException e) {

          

          
System.out.println(e.getMessage());

      
}

      

      

    }

 

 

    public
void parserXml(String fileName) {

       
File inputXml=new File(fileName);

       
SAXReader saxReader = new SAXReader();

       
try {

          
Document document = saxReader.read(inputXml);

          
Element employees=document.getRootElement();

          
for(Iterator i = employees.elementIterator(); i.hasNext();){

              
Element employee = (Element) i.next();

              
for(Iterator j = employee.elementIterator(); j.hasNext();){

                  
Element node=(Element) j.next();

                  
System.out.println(node.getName()+“:”+node.getText());

              
}

 

          
}

      
} catch (DocumentException e) {

          
System.out.println(e.getMessage());

      
}

    
System.out.println(“dom4j parserXml”);

    }

 

 

}

4. JDOM生成和解析XML

       
为减少DOM、SAX的编码量,出现了JDOM;优点:20-80原则,极大减少了代码量。使用场合:要实现的功能简单,如解析、创建等,但在底层,JDOM还是使用SAX(最常用)、DOM、Xanan文档。

package com.alisoft.facepay.framework.bean;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.List;

import org.jdom.Document;

import org.jdom.Element;

import org.jdom.JDOMException;

import org.jdom.input.SAXBuilder;

import org.jdom.output.XMLOutputter;

 

public class JDomDemo implements XmlDocument {

 

    public
void createXml(String fileName) {

     
Document document;

     
Element  root;

     
root=new Element(“employees”);

     
document=new Document(root);

     
Element employee=new Element(“employee”);

     
root.adddescription(employee);

     
Element name=new Element(“name”);

     
name.setText(“ddvip”);

     
employee.adddescription(name);

     
Element sex=new Element(“sex”);

     
sex.setText(“m”);

     
employee.adddescription(sex);

     
Element age=new Element(“age”);

     
age.setText(“23″);

     
employee.adddescription(age);

     
XMLOutputter XMLOut = new XMLOutputter();

     
try {

      
XMLOut.output(document, new FileOutputStream(fileName));

    } catch
(FileNotFoundException e) {

      
e.printStackTrace();

    } catch
(IOException e) {

      
e.printStackTrace();

    }

 

    }

 

    public
void parserXml(String fileName) {

      
SAXBuilder builder=new SAXBuilder(false);

      
try {

          
Document document=builder.build(fileName);

          
Element employees=document.getRootElement();

          
List employeeList=employees.getChildren(“employee”);

          
for(int i=0;i

             
Element employee=(Element)employeeList.get(i);

             
List employeeInfo=employee.getChildren();

             
for(int j=0;j

             
System.out.println(((Element)employeeInfo.get(j)).getName()+“:”+((Element)employeeInfo.get(j)).getValue());

                 

             
}

          
}

      
} catch (JDOMException e) {

      

          
e.printStackTrace();

      
} catch (IOException e) {

      

          
e.printStackTrace();

      
}

 

    }

}

  

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/gundsoul/archive/2009/07/05/4322749.aspx

SGML

Standardized Generalized Markup Language的缩写, 意思是标准通用标记语言。

 


 

XML(eXtensible Markup Language)

即可扩展标记语言,它与HTML一样,都是处于SGML,标准通用语言。Xml是Internet环境中跨平台的,依赖于内容的技术,是当前处理结构化文档信息的有力工具。扩展标记语言XML是一种简单的数据存储语言,使用一系列简单的标记描述数据,而这些标记可以用方便的方式建立,虽然XML占用的空间比二进制数据要占用更多的空间,但XML极其简单易于掌握和使用。