C/C ++ developers: enrich your xml Toolkit

Source: Internet
Author: User
Tags soap client xml attribute xml parser xslt xslt processor xquery

Content:
Two tools
Design your own XML Dialect
Design Tools
C and C ++ tools
Parser
XML Conversion: XSLT and XQuery
Messaging: XML-RPC and soap tools
Conclusion
XML terminology
References
About the author
Comments on this article


Related content:
Java developers' XML toolbox
XML toolbox for Perl developers
XML toolbox for PHP developers
More references for DW XML

Suggestions on tools for C and C ++ programmers who use XML in a step-by-step manner

Rick Parrish (rfmobile@swbell.net)
Independent consultant
September 2001

This article describes the C and C ++ programmers who are not familiar with XML Development and outlines the tools to be prepared for XML development. Tool table outlines common XML tools such as IDE and pattern designer, parser, XSLT tool, soap and XML-RPC library, and other libraries that can be used in C and/or C ++ or are actually written in C and/or C ++. This article includes suggestions for installing open source libraries on Windows, UNIX, and Linux, as well as a brief vocabulary of key XML terms.

It seems that some new XML-related tools released in the form of source code are all written in Java. Despite the obvious advantages of Java in the XML arena, many C/C ++ programmers are still developing XML, and many XML tools are currently available for C and C ++ programmers. We will face XML library problems, such as verification, pattern and API model. Next, we will study the collection of common XML tools, such as IDE and pattern designer. Finally, we will use a list to summarize and discuss the libraries that can be used in C and/or C ++ or actually written in C and/or C ++.

In this article, we will skip the argument about using XML, and I assume you have a good reason to wait for this technology to be mastered. In addition, we will leave a more detailed description of XML to the background resources in the references. It is enough to say that XML is the standard for data exchange (not just the file format. Data can be exchanged in the form of application files in XML format, or through network connections, this network connection only exists for a moment before it is abandoned because of the end of the online transaction or the disconnection of the network connection.

In addition, this article is not a comparative comment on the evaluation tool. My purpose is to describe the types of tools you may need and to indicate possible candidate tools to you. You still need to study, test, and compare tool features as needed to assemble the final toolbox.

Two tools
To merge XML into your own software project, you should have two tools in your toolbox. The first is the dialect designer (or, more appropriately, the pattern designer "). The second set of tools includes adding the parsing and XML generation features to the software library of the application.

Design your own XML Dialect
XML dialects are just a special set of XML tags and some rules about how to combine these tags. Currently, two main ways to specify or define XML dialects are through document type definition (DTD) or XML mode. I will call bothMode.

Your project domain may already have a specific pattern designed for you. If not, you can use the plain text editor to create your own mode. A more refined method is to use the true syntax that can be checkedDialect designer. (This mode does not work when you try to verify XML data in the wrong mode in the future .)

Design Tools
Currently, most programmers use text editors-especially text editors found in IDE-with formal macro and template support and can be used for some features, for example, a word or phrase that highlights the syntax and automatically completes partial input. Therefore, I omitted the discussion about any XML editor that only executes syntax highlighting and is automatically completed. Microsoft Word or Emacs macros can implement these features, so "XML editor" should have more features.

The tools shown in Table 1 are classified into three categories:

  • IDE (integrated development environment, that is, Swiss Army Knife method)
  • Schema-sensitive XML editor (supplement the license tag structure and attributes found in the schema or DTD)
  • Pattern designer (used to write your own pattern or DTD)

Because all the tools in Table 1 run the application, therefore, they are suitable for all XML developers-not only those who use C ++ (different from the tools listed in other tables in this article ).

Table 1. dialect design tools for various platforms

Product Supplier Description License Platform
Turbo XML Tibco/extensibility XML mode/DTD designer and IDE Business Java, Win32
Komodo Active State XML editor and IDE Business Linux, Win32, and others
XML spy Altova IDE for XML editing and Pattern Design Business Win32
XML notepad Microsoft XML editor Free Win32
Morphon XML Lunatech Research Schema-sensitive XML data editor Business Java
Xed University of Edinburgh Schema-sensitive XML data editor Non-commercial Win32, Linux, and Unix
Xeena IBM alphaWorks Schema-sensitive XML data editor Free trial/commercial Mac, UNIX, Win32
Visual XML Pierlou Schema-sensitive XML data editor Non-commercial Java
Netpadd Phillip lenssen Microsoft XML notepad substitutes Non-commercial Win32
Xmetal Softquad DTD-sensitive XML editor Business Win32
Merlot Channelpoint Visual XML editor; Supports the DTD plug-in Non-commercial Java
XML validator Elcel Technologies Command Line XML verification tool Non-commercial Win32
XML Canon Elcel Technologies Combine XML data with DTD to generate standard XML Non-commercial Win32

C and C ++ tools
The rest of this article provides the basis for adding XML functions to C/C ++ programmers through the software library. In the next section of this article, you will find more command line utilities that are included as testing and/or sample programs. For example, transformiix can be used as a library, Perl module, or command line tool.

Issuing Licenses

In all tool tables,BusinessA license indicates that the tool must be purchased before it can be used in the product environment. Trial versions (with time constraints or with major features disabled) are generally available for download and evaluation. All other tools have a non-commercial license and can be used without payment, but if you use them in commercial projects, please ensure that you will comply with the license terms for use. For example, any open source code used as a shared library or dll should comply with the open source code License Agreement (usually lgpl) attached to these XML libraries ). In the table, the type of non-commercial license is specified when the license type may be determined by Incomplete installation tools. This table usesNon-commercialTo specify a free software with vague license terms.

Common open source code is Apache, GPL, BSD, and lgpl. GPL Code cannot be included in commercial software packages, while Apache and lgpl code can be used in software sold. These four products are restricted to using their names in derived products without permission.

So far, I have tried to use as few XML-related terms as possible. However, if you are not familiar with the basic XML knowledge before reading it, you may want to browse the terms defined in the XML terminology sidebar. These terms will help you understand the rest of this article and help you pick out their features when you go deep into the tools and libraries you have mentioned.

Parser
Once you have a DTD or schema and an XML document that matches it, you need a parser to read and interpret the XML document. Table 2 lists the parser libraries of C/C ++ developers. However, a little background knowledge is required when you start to study the grid in a table.

Verify
The XML Parser has two forms: verification and non-verification. Which one do you need? If you do not use a formal DTD or mode, verification features are not important to you. If you have or are planning to use a DTD or mode, you may prefer to verify the parser. (In this case, I suggest you also learn how to read and manually write the DTD/mode so that you can handle errors when verification issues occur. Sometimes, errors are in the DTD/mode, so you can debug the DTD/mode file and XML data .)

Parser API Model
Two common API models used to combine software and XML parser are: document model and event model. The document API Model parses XML data to generate an object. The object abstracts the content of the document into a tree structure. The application operates on this tree object. The event API model uses the callback mechanism to notify the application of the XML data structure. Events/callbacks usually occur during parsing.

API standards: Dom and sax
Generally, the parser API model has been further improved to a specific API standard. W3C has recommended dom (level 1 and level 2, level 3 being drafted) as an API Model for standardized documents. Although Sax is not a W3C project, it already occupies the status of the standard event API model.

W3C Standard
When comparing the features of the parser and other XML tools, find W3C-recommended and emerging specifications, such as namespace, XPath, xlink, xinclude, and xinfoset. Keep in mind that the XML technology is very mature, and the support for level 1 norms (such as Dom) may lack the important functions introduced in level 2 of this specification. If the features in the latest standard form are important to your project, select a tool accordingly.

Read the table below
In Table 2, the "event" column specifies a parser that supports a push or event model API (such as sax. The document column specifies a parser that supports pulling or document model APIs (such as DOM. As before, this table lists commercial and non-commercial tools (see issuing licenses on the sidebar for details about software licenses ).

Table 2. Parser for C/C ++ developers

Library Supplier Event Document Features License
Expat James Clark/expat team The local host and the sax - A very fast PUSH model parser with a local API and a sax package. Lgpl (free)
Libxml Gnome Sax Dom Very strong; Sax and Dom wrappers; performs DTD Verification Lgpl (free)
MSXML Microsoft Sax Dom Win32 Microsoft XML library EULA (free)
Xerces Apache Software Foundation Sax Dom Perform Sax and Dom Level 1 and 2; DTD verification; added XML Mode Apache (free)
Xtl Vivid Creations Sax Dom STL-based XML toolkit with Sax and Dom Business
Rxp University of Edinburgh - Local Machine Verify the XML parser that understands the namespace written in C GPL (free)
Xml4c IBM alphaWorks Sax Dom Xerces variants initiated by IBM Apache (free)
Oracle xdk 8i Oracle Sax Dom XML toolbox for C ++ sponsored by Oracle Non-commercial
Pull parser Extreme! Lab - Local Machine Lightweight XML toolkit for C ++ initiated by the University of India Non-commercial
XML Booster Phidani Software - Local Machine Parser Generator to generate the C source code parser Business

Top three open source codes
The three most popular open source XML libraries are expat, libxml, and xerces. These three are all cross-platform. Each of them serves as the basis for the implementation of the XSLT library. Once the basic XML needs are met, it will give you a way to grow.

  • Expat is an open source event-Oriented XML parsing library created by James Clark. He has transferred the project to a group in SourceForge. There is a sax package for use. Expat parsers can be found in many projects, such as open source browsers Mozilla, XSLT processor transformiix, and RDF tool repat.
  • Libxml provides a dual API for operations similar to Sax and Dom. It supports DTD verification, and the XSLT processor in GNOMELibxslt. Libxml has been rewritten and published as libxml (2). It may also be calledLibxml2. Users of this database should ensure that they have the current version.
  • Xerces is a very robust library with a large number of documents. It serves as the basis for the IBM alphaWorks xml4c library. Xerces is also used in the Apache XSLT processor xalan. Xerces supports Dom, sax, and DTD verification. The latest version reads and explains some "W3C XML Schema recommendations" (we plan to implement full XML Schema support by the end of 2001 ).

Compiling and linking one of the three most popular libraries to your project is effortless. Most software packages contain detailed descriptions of each platform. Here are some sample installation instructions.

Build an Open Source library on Windows
Build from scratch on WindowsLibxmlThere are four simple steps:

  1. Download the source tarball file.
  2. Decompress the content to a directory using programs such as WinZip. Confirm the instructions to understand how the compression utility is retainedLibxmlThe path name of any subdirectory that may be required.
  3. Positioning./win32/dspSubfolderslibxml2.dswFile and open it from MS developer studio.
  4. Select build all from the top menu in devstudio. This will build all the samples and test programs and run the libxml DLL they need.

You can use the above steps to build xerces on Windows. The only difference is that./c/samples/Projects/Win32/VC6Subfolderssamples.dswWorkspace files.

Expat has started to include the DSP project makefile. ViewlibAndxmlwfSubfolders.

Build an Open Source library on UNIX
For projects running on Linux or UNIX, in most cases, you can untar the source code to an empty directory and set some options, enter "make" to build the shared library. Solaris users: do not forget to use the GNU unpacking utility. In the bash shell in slackware Linux, I use the following code:

tar -x 

XML and COM
MSXML is Microsoft's patented XML for Windows operating systems. It is implemented as a Scriptable COM object set, so it can work well in other language environments, A large number of documents are provided. This library supports Dom and has a local document-oriented interface. It also supports sax events.

As a substitute for MSXML, the "Apache XML project" xerces library comes with a com package, which can act as a copy of MSXML in many cases. Vivid creations provides the com package of the sax and Dom APIs in its xtl library. This product is also a substitute for MSXML.

XML Conversion: XSLT and XQuery
ConversionIt is the next step in XML development from processing XML data at the element and attribute levels. XML Conversion operations are performed on incoming XML data to generate xml output. Conversion can reorganize the tag structure, Add/Remove tags and attributes, and filter to enlarge the selected part of the XML data.

The XQuery document calls the conversion process a query, but the meaning is the same.

XSLT and XQuery are XML dialects used to specify how to perform such operations on random XML data. You can write a script file and use XSLT or xqurey instead of XML to load some XML data into the Dom. The program must manipulate the DOM version to produce the expected results. This more general method will produce better flexibility and shorten the development time. Now, your web developers (who are not C/C ++ programmers) can write their own XML transformations, which allows c ++ programmers to do more complex work.

Table 3. C/C ++ conversion/query database

Library Supplier Features License
Libxslt Gnome Built on libxml Non-commercial
Xalan Apache Built on the xerces parser Apache (free)
Transformiix Mitre XSLT processor built on expat Non-commercial
TC Oliver gerardin XSLT compiler to generate C code Non-commercial
Sablotron Ginger Alliance XSL Engine Non-commercial

Messaging: XML-RPC and soap tools
For this article,Message transmissionMeans to allow two software proxies to communicate with each other. This type of message transmission is sometimes called message-oriented middleware. (This is not like AOL, MSN or ICQ message transmission, OK? NowYesThe results of an XML-based instant messaging protocol that is still in the unfinished phase are called jabber. I have included a link to your reference to satisfy your curiosity, but again I declare that it is not what I want to discuss here .)

The use of XML for message passing has become so popular that there are already two alternatives: XML-RPC and soap. The most notable feature of these protocols is that, depending on the tools developers use for implementation, clients, servers, and devices of the same level may be quite different. Although all developers are used to using their preferred language, development toolkit, or software library, they can still work together.

(Note: Gregor purdy has written an outstanding XML-RPC comment with the proposed alternative method (see references )).

Table 4 contains databases for message-oriented middleware categories. This is not a detailed list of resources in this category. Some new tools are developing rapidly, but it is a good starting point.

Table 4. C/C ++ message passing Library

Library Supplier Features License Platform
4s4c soap Service Simon fell Open source soap results Non-commercial Linux, UNIX, Win32
Soap Client SQL data C ++ soap client toolbox Business Win32
Soap Components Mozilla.org Scriptable xp com components Non-commercial Many
XML-RPC for C/C ++ First peer XML-RPC library written in C Language Non-commercial Linux, UNIX, Win32
XML-RPC Components Mozilla.org Scriptable xp com components Non-commercial Many
XML-RPC for C/C ++ Epinions XML-RPC library written in C Language Non-commercial Linux, UNIX, Win32

Digress
These tools should give your xml toolbox a good start point. If you want to recommend other tried C/C ++ tools for XML, or you want to post any other comments, please join in the discussion that is attached to this article (Please use the link in "references" or click the "discussion" icon at the top or bottom of the article page ).

XML terminology

These XML terms may come in handy when you understand the libraries discussed in this article:

  • Document model:The technology used to parse and manipulate XML data as a tree object, also known as the "pull" model. See dom api standard as an example.
  • DOM:The Document Object Model is a special tree-structure programming model for XML documents. W3C describes it as a standard. The Dom standard is divided into three levels. Dom 1.0 refers to Dom level 1.0 consistency; DOM Level 2 is the latest specification, which W3C recognizes as "recommendation"; DOM Level 3 is being drafted during the creation of this article.
  • DTD:Document Type Definition. An XML file defines XML elements and the XML attributes of those elements, and specifies the rules for how to nest XML tags and what data elements can contain. For more information, see Introduction to XML and DTD in Jane Fung.
  • Event model:It is used to parse XML data by using callback or processing programs. It is also called a "push" model. For example,SeeAPI standard.
  • Namespace:Identify the XML tag methods from different DTD or modes so that they can be mixed in the same XML document. RDF relies heavily on this feature. The XML 1.0 mark "xmlns" can be used to define namespaces in XML documents.
  • RDF:The Resource Description Framework is a compression XML dialect that associates XML Attribute data with information stored elsewhere. The license for your driver is similar to describing your rdf xml file.
  • Sax:Simple API for XML is a standard programming interface used by the XML parser. Sax uses an event-oriented programming model. Sax is the de facto standard first developed by David Megginson and is now maintained by the XML-dev email list.
  • Soap:The Simple Object Access Protocol is similar to a XML-RPC (SeeXML-RPC) network protocol. By using soap, an application can create a remote object, call methods on the object, and retrieve results.
  • Verification:Verify that the well-structured XML documents are correct about the DTD and schema.
  • Good structure:An XML document whose tags and data comply with the XML 1.0 syntax.
  • W3C:The World Wide Web alliance has become an important standard subject for most XML-related technologies. W3C calls the final accepted specification "recommendation" rather than the standard ).
  • 1.0 XML:The first XML syntax standard praised by W3C. It establishes basic rules for XML data. For example, all tags must follow a slash (/) End, for example:, Or followed by an end tag, such: close the tag on your way out.
  • XML-RPC:XML remote process call. XML-RPC is the standard XML dialect for cross-network call methods and services; as you think, XML-RPC uses XML to deliver messages between clients and servers.
  • XML mode:XML is a W3C recommendation. It is similar to DTD and is used to define the structure of XML documents, but it has better flexibility. The XML mode uses the XML 1.0 syntax to specify the mode, which is opposite to the earlier SGML syntax used for DTD.
  • XQuery:Some of its functions are similar to XSLT, but they are designed to serve as a query language for XML data-similar to using SQL in relational databases. As a standard, it is not as mature as XSLT, and XQuery may become the SQL statement of the next decade.
  • XSLT:Extensible style language conversion, an XML dialect used to convert XML content. Apply the XSLT file to some XML input data to generate the expected XML output data.

References

  • Add your comments or questions about the C/C ++ tool to the discussion in this article. (You can use this link or click the "discussion" icon at the top or bottom of the page .)
  • Visit the W3C XML page, which provides most of the content in the XML specification.
  • Visit the summary site of XML-related software.
  • Please use zvon's general XML tutorial or Doug Tidwell of developerworks to get the basic XML knowledge.
  • Read about Howard Katz's XQuery.
  • Read the excellent critique of XML-RPC written by Gregor Purdy carefully.
  • Learn the basics of writing a DTD in Jane Fung's Document XML and DTD.
  • In Michael Kay's technical overview, what type of language is XSLT? To understand XSLT.
  • Learn more about jabberOthersType of message transmission (instant message transmission) information.
  • Learn the XML Certification guidelines of IBM certified Developer Program to master the XML developer skills.

XML standards mentioned in this Article

  • XML specification 1.0: W3C Core XML 1.0 specification.
  • Dom level 1.0: W3C documentation Object Model Level 1 API recommendation.
  • Dom level 2.0: W3C documentation Object Model Level 2 API recommendation.
  • Sax/sax2: the de facto standard of the Simple API for XML event model.
  • Namespace: W3C recommendation for processing XML Namespaces.
  • XML mode: Everything about W3C XML mode recommendation
About the author
Rick is an old-qualified programmer. His career is to stock up and overcome the deadline. At the same time, he gives the waitress a generous tip that makes them blushing. His name has been spread throughout every cafe in the town. He also enjoys speaking at technology-themed seminars. His design is unconventional. Now he is studying more fashionable modeling methods, such as UML. The bumper of his car says: "I for XHTML .". You can contact Rick through a rfmobile@swbell.net.

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.