Xport Usage: Overview

Xport is a class template library, which you can use in your projects to generate and parse (x)html documents and stylesheets. Xport is not platform or compiler specific, and is compatible with VC6, VC7, VC8, GCC, and most other compilers.

Although Xport consists entirely of class templates, you need know nothing of templates to use Xport and all it's features. Type aliases are provided in Xport to allow it's use without working directly with the template classes. For example, the following code snippet creates and saves a basic xhtml strict document.

// bring namespace into current scope
using namespace Xport;

// create an xhtml document with the root elements (<html>, <head>, and <body>)
document doc(root_doc);

// insert a paragraph element into the document's body element, returning an iterator
markup::iterator it = doc.body()->insert(element(p));
it->insert("This is the first paragraph of the document");

// insert a paragraph into the document using the inserter operator
*doc.body() << (element(p) << "This is the second paragraph of the document");

// write the document
doc.write("c:/myDoc.htm");
    

As illustrated above, there are no direct usages of templates. This snippet also illustrates the ease of creating an (x)html document with Xport. Creating stylesheets is just as simple.

Although Xport consists of a number of class templates, only a few of these are used directly. All Xports classes, or types can be divided into one of two categories, interface classes and helper classes, or more precisely, interface types, and helper types.

Xport's interface types are listed below. The class template is first listed, followed by the type aliases which should be used directly by users. The type aliases prefixed with a 'w' denote the wide character form of the type. Type aliases prefixed with a 't' denote the xhtml transitional doctype form of the types. Type aliases prefixed with an 'f' denote the xhtml frameset doctype form of the types. Those with no prefix denote the xhtml strict narrow character form of the types.

class template type aliases
xhtml strict wchar xhtml strict xhtml transitional wchar xhtml transitional xhtml frameset wchar xhtml frameset
xhtml_doc document wdocument tdocument wtdocument fdocument wfdocument
xhtml_element element welement telement wtelement felement wfelement
xhtml_markup markup wmarkup tmarkup wtmarkup fmarkup wfmarkup
xhtml_formatter formatter wformatter tformatter wtformatter fformatter wfformatter
xhtml_parser parser wparser tparser wtparser fparser wfparser
xhtml_comment comment wcomment tcomment wtcomment fcomment wfcomment
xhtml_ processing_instruction procinstr wprocinstr tprocinstr wtprocinstr fprocinstr wfprocinstr

Of the types listed above, xhtml strict types were chosen to be the default types, thus were assigned no prefixes. You're encouraged to use these xhtml strict types, and in doing so, need only use the types document, element, markup, formatter, parser, comment, and procinstr to create and parse xhtml documents.

Xport also defines class templates for stylesheet entities. These classes are parametized only on the character type, and also have typedef alias defined for easy usage. The list below displays the stylesheet types used for both standard narrow character, and wide character usage.

Narrow Character
  • stylesheet
  • stylesheet_rule
  • stylesheet_item
  • stylesheet_comment
  • stylesheet_import
  • declaration
  • stylesheet_formatter
Wide Character
  • wstylesheet
  • wstylesheet_rule
  • wstylesheet_item
  • wstylesheet_comment
  • wstylesheet_import
  • wdeclaration
  • wstylesheet_formatter

See stylesheet generation for more details on using Xport's stylesheet features.

Work Time Studio

Datasoft Solutions is proud to present their landmark product, Work Time Studio. Utilizing the tree container library, Work Time Studio provides unparalleled features in personal time, project and task management software. If you're looking for a way to increase your productivity, visit Work Time Studio's product website, and start being more productive today.