W3C app_multiplexed

app_multiplexed

Basics | Features | Release Notes | Get/Compile Source | Help

The app_multiplexed is a utility to create compound or multiplexed documents containing an XHTML-Print document and all its referenced entities. The format of the multiplexed document is given by RFC3391 - The MIME Application/Vnd.pwg-multiplexed Content-type.

Basics

Definition of a Multiplexed Document

RFC3391 - The MIME Application/Vnd.pwg-multiplexed Content-type is used by XHTML-Print as a file format to use when bundling an XHTML-Print document and its associate image and style sheet files into a single, compound document. The app_multiplexed utility creates such a compound document interleaving or multiplexing image and style sheet files with the XHTML-Print document that references it.

The compound document produced by app_multiplexed conforms to the RFC3391:

A simple example

The following is a simple XHTML-Print document that prints a single page with the words "Hello world!":

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//PWG//DTD XHTML-Print 1.0//EN"
 "http://www.pwg.org/xhtml-print/xhtml-print10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>greet</title>
</head>
<body > 
<p>Hello world!</p>
</body>
</html>

The following is the document above as a multiplexed document containing the single message that is the XHTML-Print document in a single chunk.

Content-Type: application/vnd.pwg-multiplexed; type=application/vnd.pwg-xhtml-print+xml

CHK 1 371 LAST
Content-Type: application/vnd.pwg-xhtml-print+xml
Content-Location: helloworld.htm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//PWG//DTD XHTML-Print 1.0//EN"
 "http://www.pwg.org/xhtml-print/xhtml-print10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>greet</title>
</head>
<body >
<p>Hello world!</p>
</body>
</html>

CHK 0 0 LAST

An example document with an image

The following example contains a reference to "image.jpg":

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//PWG//DTD XHTML-Print 1.0//EN"
 "http://www.pwg.org/xhtml-print/xhtml-print10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Image Reference</title>
</head>
<body > 
<p><img src="tests/image.jpg" width="100" height="100" /></p>
</body>
</html>

Diagram of how a doc and image are combinged into a mx docThe multiplexed document version of this example, contains two messages: the xhtml-print document (Message 1) and the image, tests/image.jpg (Message 2). The both messages are divided into two chunks and interleaved.

The diagram on the right illustrates how the two messages contribute to making the single, compound, multiplexed document that starts with the required Content-Type header and the first chunk of the first message.

The first chunk of the second message follows directly after the reference to it in the first message, which causes the division of the first message into two chunks.

The second message contains the JPEG image, so it is divided into two chunks.  The first chunk contains the image header, which provides enough immediate information so that the page can be laid out. The second chunk contains the image data approximately at the end of the page, so that it is available as the printer needs it and not before.

The document ends with the required empty chunk for message zero.

The multiplexed document below is constructed from the XHTML-Print document in this example:

Content-Type: application/vnd.pwg-multiplexed; type=application/vnd.pwg-xhtml-print+xml
CHK 1 395 MORE
Content-Type: application/vnd.pwg-xhtml-print+xml
Content-Location: imgref.htm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//PWG//DTD XHTML-Print 1.0//EN"
 "http://www.pwg.org/xhtml-print/xhtml-print10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Image Reference</title>
</head>
<body >
<p><img src="tests/image.jpg" width="100" height="100" /> 
CHK 2 686 MORE
Content-Type: image/jpeg
Content-Location: tests/image.jpg 
 ...686 bytes of JPEG image header from message two ...
CHK 1 24 LAST
</p>
</body>
</html>
CHK 2 2516 LAST
  ...remaining 2516 bytes of JPEG image header from message two 
CHK 0 0 LAST

Interleaving Multiple Images

When a document references multiple images, each image is a separate message divided into two chunks: the first chunk containing the image header, the second the image data. Each image header chunk follows directly after an image reference in the XHTML-Print document. The image data chucks are collected a placed in the document at approximately where the printer will need them when printing the page.

How app_multiplexed works

The app_multiplexed utility :

  1. reads an XHTML-Print document,
  2. collects referenced entities and
  3. combines them into a multiplexed document.

Reading an XHTML-Print document

This processing involves looking for URI's in the attributes of the img and object elements, as well as the url function within style sheets and style attributes. For example:


Features

Creating a multiplexed document

The simplest way to create a multiplexed file is by invoking app_multiplexed from the command line with the name of a file containing an XHTML-Print document:

bash-2.04$ app_multiplexed helloworld.htm > helloworld.mx

In this situation app_multiplexed accepts one file that is assumed to contain an XHTML-Print document, scans the document for URIs, attempts to collect the referenced entities, constructs the multiplexed document and writes it to standard out.


Help

The man page below is the current source of help for this utility.

Man Page


app_multiplexed(1)

name

app_multiplexed - creates a multiplexed document from an XHTML-Print document

synopsis

app_multiplexed [OPTION]... [-] [FILE] ...

description

Reads FILE(s) and their associated resources (either images or style sheets) and by writes a multiplexed file to standard out when a single input file is specified on the command line. If multiple files are given, app_multiplexed writes a multiplexed file for each input file using either the default file suffix, "mx" or the suffix given by the -output-prefix option at the end of the input file name. For example, "app_multiplexed doc1.htm doc2.htm" results in doc1.htm.mx and doc2.htm.mx.

If no files are given on the command line, then input is taken from standard in and the multiplexed file is written to standard out. For example,
    "cat doc.htm | app_multiplexed | lp"

Command Line Options

-base
Defines the base to use when resolving relative URIs.
-encode
Encodes MIME headers as required by RFC 2047 and RFC 1738. Also performs folding of field bodies longer than 40 characters.
-content-disp="value"
Adds a Content-Disposition="value" header to each chunk.
-cid
Adds a Content-ID header to each chunk
-reusemsg
Reuses message numbers of message that are complete. For example give a two page document that a difference image on each page, the document will be message "1", the image on the first page is message "2". If all the chunks of message "2" occur before the first chunk of the image on the second page, then when this option is used, the message number of the second image is "2" rather than "3".
-force-before-root
Arranges message chunks so that image headers are before the document and image data after the document.
-output-prefix
Sets the file suffix to use when writing multiplexed documents to a file rather than standard out. The default suffix is "mx".
-interleave="list"
Interleaves the chunks of the images in the given, comma separated list. For example, "app_multiplexed.exe -interleave="tests/image.jpg,image.jpg" imgref.htm" creates a multiplexed document where the data of the images named in the value of -interleave, are divided into multiple chunks and the chunks of the two messages are interleaved.
-one-obj
Only includes one copy of an image that is referenced multiple times.

Reporting Bugs

Report bugs to www-html-testsuite@w3.org. No guarantee of support is implied by a bug report.

copyright

Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

See Also

See RFC3391 - The MIME Application/Vnd.pwg-multiplexed Content-type for more information about the multiplexed file format.