Processing XML files using notepad++ plug-in functionality and Java JNI Technology

Source: Internet
Author: User
Keywords Java jni technology Notepad++ xml file plug-in function

Fastinfoset as a standard XML serialization means, the XML on the basis of the compression to achieve excellent support, but the lack of direct reading tools, the user caused a certain difficulty, the use of notepad++ plug-in function and Java JNI technology, combining the characteristics of both Directly to the Fastinfoset file in the notepad++ open, to solve the user two times the trouble of editing, but also fully utilize the notepad++ of XML file editing advantages.

Fastinfoset has customized a way of processing XML information collections at the binary level, and this special serialization has special advantages over the size and parsing speed of ordinary XML documents.

Notepad++ is an excellent http://www.aliyun.com/zixun/aggregation/18444.html "> text editing software, open source, free and multiple plug-in support makes it one of the most popular editing software, The powerful plug-in feature allows notepad++ to support a wide variety of text files, as shown in the following illustration:

Figure 1. notepad++ Display XML

For XML, excellent processing capability is embodied in label coloring and tree folding, but notepad++ can not open the Fastinfoset document directly, this article has solved this problem for the purpose of using notepad++ plug-in technology to directly open and save Fastinfoset document. Includes the following issues:

Open, Storage Fastinfoset Library is provided by Java, must establish JNI call structure to manage code, plug-in development model, including the focus on the use of functions, call the process and development code, JNI call.

Fastinfoset file Processing

Brief introduction of Fastinfoset technology

Fastinfoset uses the features of a lot of repetitive information that exists in real-world XML files, such as the books.xml mentioned earlier, to see a lot of duplicate tags, and then use this technique of processing characters to compress XML files and improve access speed. These techniques include dynamic tables, original word sets, and external vocabularies.

Open and Save Fastinfoset

Part of the technology from GlassFish, users can access http://fi.java.net to get Fast infoset technical support, because Java technology, Fastinfoset interfaces are written in Java, Some of the code looks like this:

Open the Fastinfoset document


Listing 1. Open Fastinfoset Document


Defaultcontenthandler builder = new Defaultcontenthandler (); Instantiate the FI SAX parser XMLReader saxreader = new Saxdocumentparser (); Saxreader.setcontenthandler (builder); Parse The Fast infoset document InputSource InputSource = new InputSource (stream); Saxreader.parse (InputSource); Save Fastinfoset Document


Listing 2. Save Fastinfoset Document


Final Java.io.StringReader reader = new Java.io.StringReader (savestring); Get the "input stream for" XML document InputStream xmldocument = new InputStream () {@Override public int read () throws IOException {//TODO auto-generated Method stub return Reader.read ();}; Set up output stream for fast Infoset document OutputStream fidocument = new FileOutputStream (new File (FilePath)); Create Fast Infoset SAX serializer Saxdocumentserializer saxdocumentserializer = new Saxdocumentserializer (); Set the output stream Saxdocumentserializer.setoutputstream (fidocument); Instantiate JAXP SAX parser factory SAXParserFactory saxparserfactory = Saxparserfactory.newinstance (); /* Set parser to is namespace aware * Very important to do otherwise invalid FI documents would be * created by the saxdocumentserial Izer * * Saxparserfactory.setnamespaceaware (TRUE); Instantiate the JAXP SAX parser saxparser saxparser = Saxparserfactory.newsaxparser (); Set the lexical handler Saxparser.sEtproperty ("Http://xml.org/sax/properties/lexical-handler", New Fastinfosetdefaulthandler ()); Parse the XML document and convert to a fast Infoset document Saxparser.parse (XmlDocument, Saxdocumentserializer);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.