Please refer to theerrata for this document, which may include some normative corrections.
See alsotranslations.
Copyright©2003-2011W3C® (MIT,ERCIM,Keio),All Rights Reserved. W3Cliability,trademark anddocumentuse rules apply.
This document describes the syntax and semantics for the Ink Markup Language. The Ink Markup Language serves as the data format forrepresenting ink entered with an electronic pen or stylus. Themarkup allows for the input and processing of handwriting,gestures, sketches, music and other notational languages inapplications. It provides a common format for the exchange of inkdata between components such as handwriting and gesturerecognizers, signature verifiers, and other ink-aware modules. It may be used in theW3C MultimodalInteraction Framework as proposed by theW3C Multimodal InteractionActivity.
This section describes the status of this document at thetime of its publication. Other documents may supersede thisdocument. A list of current W3C publications and the latestrevision of this technical report can be found in theW3C technical reports index athttp://www.w3.org/TR/.
This is theRecommendationof "Ink Markup Language (InkML)".It has been produced by theMultimodal Interaction Working Group,which is part of theMultimodal Interaction Activity.
Comments are welcome onwww-multimodal@w3.org(archive).SeeW3C mailing list and archiveusage guidelines.
The design of InkML has been widely reviewed(see the disposition of comments)and satisfies the Working Group's technical requirements.A list of implementations is included in theInkML 1.0 Implementation Report.There are no substantial changes from the10 May 2011 Proposed Recommendation.
This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.
This specification describes markup for representing ink entered with an electronic pen or stylus and forms part of the proposals for theW3C Multimodal InteractionFramework.
This document was produced by a group operating under the5 February 2004 W3C Patent Policy. W3C maintains apublic list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent.
<ink>
element<traceFormat>
element<channel>
element<intermittentChannels>
element<trace>
element<traceGroup>
element<traceView>
element<mapping>
element<bind>
element<table>
element<affine>
element<definitions>
elementAs more electronic devices with pen interfaces have and continueto become available for entering and manipulating information,applications need to be more effective at using this method ofinput. Handwriting is a powerful and versatile input modality thatis very familiar for most users since everyone learns to write inschool. Hence, users will tend to use this as a mode of input andcontrol when available.
A pen-based interface is enabled by a device that allowsmovements of the pen to be captured as digital ink. A number ofmethods may be used for ink capture, including those based on radiofrequency, optical tracking, physical pressure, or othertechnologies. Digital ink can be passed on to recognition softwarethat will convert the pen input into appropriate computer actions.Alternatively, the handwritten input can be organized into inkdocuments, notes or messages that can be stored for later retrievalor exchanged through telecommunications means. Such ink documentsare appealing because they capture information as the user composedit, including text in any mix of languages and drawings such asequations and graphs.
Hardware and software vendors have typically stored andrepresented digital ink using proprietary or restrictive formats.The lack of a public and comprehensive digital ink format hasseverely limited the capture, transmission, processing, andpresentation of digital ink across heterogeneous devices developedby multiple vendors. In response to this need, the Ink MarkupLanguage (InkML) provides a simple and platform-neutral data formatto promote the interchange of digital ink between softwareapplications.
InkML supports a complete and accurate representation of digitalink. In addition to the pen position over time, InkML allowsrecording of information about device characteristics and detaileddynamic behavior to support applications such as handwritingrecognition and authentication. For example, there is support torecord additional information such as pen tilt and pen tip force(often referred to as "pressure") and information about therecording device such as accuracy and dynamic distortion. InkMLalso provides features to support rendering of digital ink capturedoptically to approximate the original appearance. For example,stroke width and color information can be recorded.
It is not within the design of InkML to describe and storesemantic information, such as the plain text of ink recognized ashandwriting. Nor is it a goal of InkML to store thecontextual information about the ink, such as what kind of field ina form where ink was written. However, InkML provides meansfor extension. InkML can include XML from other schemas atspecific locations in a file or stream (see<annotationXML>
.) Additionally, InkML could be embedded within other XMLdocuments.
With the establishment of a non-proprietary ink standard, anumber of applications, old and new, are expanded where the pen canbe used as a very convenient and natural form of input. Here are afew examples.
Two-way transmission of digital ink, possibly wireless, offersmobile-device users a compelling new way to communicate. Users candraw or write with a pen on the device's screen to compose a notein their own handwriting. Such an ink note can then be addressedand delivered to other mobile users, desktop users, or faxmachines. The recipient views the message as the sender composedit, including text in any mix of languages and drawings.
A photo taken with a digital camera can be annotated with a pen;the digital ink can be coordinated with a spoken commentary. Theink annotation could be used for indexing the photo (for example,one could assign different handwritten glyphs to differentcategories of pictures).
A software application may allow users to archive handwrittennotes and later retrieve them by a variety of mechanisms.
In support of natural and robust data entry for electronic formson a wide spectrum of keyboard-less devices, a developer may define an API that takes InkML asinput for fields of the form.
Robust and flexible user interfaces can be created thatintegrate the pen with other input modalities such as speech.Multimodal applications may share context information acrossmodalities, leading to better recognition in each modalityindividually. In this setting, pen input may be used todisambiguate voice recognition and vice-versa.
The current InkML specification defines a set of primitiveelements sufficient for all basic ink applications. All content ofan InkML document is contained within a single<ink>
element. The fundamental data element inan InkML file is the<trace>
. A trace representsa sequence of contiguous ink points, where each point captures thevalues of particular quantities such as the X and Y coordinates ofthe pen's position. A sequence of traces accumulates to meaningfulunits, such as characters, words or diagrams.
In its simplest form, an InkML file with its enclosed traceslooks like this:
<ink xmlns="http://www.w3.org/2003/InkML"> <trace> 10 0, 9 14, 8 28, 7 42, 6 56, 6 70, 8 84, 8 98, 8 112, 9 126, 10 140, 13 154, 14 168, 17 182, 18 188, 23 174, 30 160, 38 147, 49 135, 58 124, 72 121, 77 135, 80 149, 82 163, 84 177, 87 191, 93 205 </trace> <trace> 130 155, 144 159, 158 160, 170 154, 179 143, 179 129, 166 125, 152 128, 140 136, 131 149, 126 163, 124 177, 128 190, 137 200, 150 208, 163 210, 178 208, 192 201, 205 192, 214 180 </trace> <trace> 227 50, 226 64, 225 78, 227 92, 228 106, 228 120, 229 134, 230 148, 234 162, 235 176, 238 190, 241 204 </trace> <trace> 282 45, 281 59, 284 73, 285 87, 287 101, 288 115, 290 129, 291 143, 294 157, 294 171, 294 185, 296 199, 300 213 </trace> <trace> 366 130, 359 143, 354 157, 349 171, 352 185, 359 197, 371 204, 385 205, 398 202, 408 191, 413 177, 413 163, 405 150, 392 143, 378 141, 365 150 </trace></ink>
These traces consist simply of X and Y value pairs, and may looklike this when rendered:
Figure 1: Example of trace rendering
Figure 1 shows a trace of a sampled handwriting signal. The dotsmark the sampling positions which were interpolated by the blueline. Green points represent pen-downs whereas red dots indicatepen-ups.
More generally, traces consist of sequences of points. Eachpoint consists of a number of coordinate values whose meanings aregiven by a<traceFormat>
element. Thesecoordinates may provide values for such quantities as pen position,angle, tip force, button states and so on.
Information about the device used to collect the ink (e.g., thesampling rate and resolution) may be specified with the<inkSource>
element.
Ink traces can have certain attributes such as color and width,writer identification, pen modes (eraser versus writing), and soon. These and other attributes are captured using the<brush>
element. Traces that share the samecharacteristics, such as being written with the same brush, can begrouped together with the<traceGroup>
element.
Ink traces may also be organized into collections forapplication-specific purposes either by grouping the traces objectsthemselves, using the<traceGroup>
element, orby reference, using the<traceView>
element.
Certain applications, such as collaborative whiteboards (whereink coming from different devices is drawn on a common canvas) ordocument review (where ink annotation from various sources arecombined), will require ink sharing. The<context>
element allows representation andgrouping of the pertinent information, such as the trace format,brush, and canvas. Canvas transformations allow ink from differentdevices to be combined and manipulated by multiple parties.
InkML supports the semantic labeling of traces with attributeson traces or collections of traces. These may be given with either<annotation>
, for text, or<annotationXML>
, for XML, usingapplication-defined encodings.
In all appropriate cases, the InkML specification definesdefault values for elements that are not specified, and rules thatestablish the scope of a given attribute.
Finally, the InkML specification is limited in scope: It iscurrently oriented to fixed Cartesian coordinate systems, it doesnot support sophisticated compression of trace data, and it doesnot support non-ink events (although the later could be handled viaannotations).
Most ink-related applications fall into two broad categories:"Streaming" and "Archival". Archival ink applications capture andstore digital ink for later processing, such as documentstorage/retrieval applications and batch forms processing . Inthese applications, an entire<ink>
element iswritten prior to processing. For ease of implementation in archivalmode, referenced elements should be defined inside a declarationblock using the<definitions>
element (seeThe Default Context section, theDefinitions section, and theArchival Applications section).
Streaming ink applications, on the other hand, transmit digitalink as it is captured, such as in the electronic whiteboard examplementioned above. In order to support a streaming style of inkmarkup generation, the InkML language supports the notion of a"current" state (e.g., the current brush) and allows forincremental changes to this state.
This document uses the following conventions:
InkML documents are well-formed XML documents which comply tothe syntax rules of this specification.
The namespace URI of InkML ishttp://www.w3.org/2003/InkML
The media type of InkML document isapplication/inkml+xml
. See theMedia Type definition for details. Thismedia type is expected to be registered with IETF.
<ink>
elementTheink
element is the root element of any InkMLinstance. When combining InkML and other XML elements withinapplications, elements from different namespaces must bedisambiguated by use of the namespace qualifier. The allowedsub-elements of theink
element can occur any numberof times, in any order.
A URI that uniquely identifies this document. No two documentswith a distinct application intent may have the samedocumentID
contents. The value of this property is anopaque URI whose interpretation is not defined in thisspecification.
<ink xmlns="http://www.w3.org/2003/InkML" documentID="uuid:6B29FC40-CA47-1067-B31D-00DD010662DA"> ...</ink>
<trace>
is the basic element used to recordthe trajectory of a pen as the user writes digital ink. Morespecifically, these recordings describe sequences of connectedpoints. On most devices, these sequences of points will be boundedby pen contact change events (pen-up and pen-down), although somedevices may simply record proximity and force data withoutproviding an interpretation of pen-up or pen-down state.
The simplest form of encoding specifies the X and Y coordinatesof each sample point. For compactness, it may be desirable tospecify absolute coordinates only for the first point in the traceand use delta-x and delta-y values to encode subsequent points.Some devices record acceleration rather than absolute or relativeposition; some provide additional data that may be encoded in thetrace, including Z coordinates or tip force, or the state of sideswitches or buttons.
These variations in the information available from different inksources, or needed by different applications, are supported inInkML through the<traceFormat>
and<trace>
elements. The<traceFormat>
element specifies the encodingformat for each sample of a recorded trace, while<trace>
elements are used to represent theactual trace data. If no<traceFormat>
isspecified, a default encoding format of X followed by Y coordinatesis assumed.
Traces generated by different devices, or used in differingapplications, may contain different types of information. InkMLdefineschannels to describe thedata that may be encoded in a trace.
A channel can be characterized as eitherregular,meaning that its value is recorded for every sample point of thetrace, orintermittent, meaning that its value may changeinfrequently and thus will not necessarily be recorded for everysample point. X and Y coordinates are examples of likely regularchannels, while the state of a pen button is likely to be anintermittent channel.
<traceFormat>
elementThe<traceFormat>
element describes theformat used to encode points within<trace>
elements. In particular, it defines the sequence of channel valuesthat occurs within<trace>
elements. The orderof declaration of channels in the<traceFormat>
element determines the order of appearance of their values within<trace>
elements.
Regular channels appear first in the<trace>
,followed by any intermittent channels. Correspondingly, the<traceFormat>
element contains an orderedsequence of<channel>
s, giving the regularchannels (if any), followed by an optional<intermittentChannels>
section. The order of thecoordinates in each point of a trace is determined by the order ofthe<channel>
elements in the trace format,including those from the intermittent channels part.
The<context>
element may use thetraceFormatRef attribute to refer to a<traceFormat>
by it's id. If no<traceFormat>
is specified in an InkML file, an application defined default trace format is used. The default trace has the reserved id "DefaultTraceFormat
" and may be explicitly referenced using theURI "#DefaultTraceFormat
".
<channel>
elementChannels are described using the<channel>
element, with various attributes.
The requiredname attribute specifies the interpretationof the channel in the trace data. The following case sensitive channel names, withtheir specified meanings, are reserved:
channel name | dimension | default unit | interpretation |
---|---|---|---|
X | length | mm | X coordinate. This is the horizontal pen position on thewriting surface, increasing to the right for +ve orientation. |
Y | length | mm | Y coordinate. This is the vertical position on the writingsurface, increasing downward for +ve orientation. |
Z | length | mm | Z coordinate. This is the height of pen above the writingsurface, increasing upward for +ve orientation. |
F | force | % | pen tip force |
S | tip switch state (touching/not touching the writingsurface) | ||
B1...Bn | side button states | ||
OTx | angle | deg | tilt along the x-axis |
OTy | angle | deg | tilt along the y-axis |
OA | angle | deg | azimuth angle of the pen (yaw) |
OE | angle | deg | elevation angle of the pen (pitch) |
OR | angle | deg | rotation (counter-clockwise rotation about pen axis ) |
C | color value as an RGB octet triple (i.e. #000000 to#FFFFFF). | ||
CR,CG,CB | color values (Red/Green/Blue) | ||
CC,CM,CY,CK | color values (Cyan/Magenta/Yellow/Black) | ||
A | transparency (device-specific encoding) | ||
W | length | mm | stroke width (orthogonal to stroke) |
BW | length | mm | brush width |
BH | length | mm | brush height |
T | time | ms | time (of the sample point) |
Thetype attribute defines the encoding type for thechannel (either boolean, decimal, or integer). Iftype isnot specified, it defaults to decimal.
A default value can be specified for the channel using thedefault attribute; the use of default values within a traceis described in the next section. If nodefault isspecified, it is assumed to be zero for integer and decimal-valuedchannels, and false for boolean channels.
Themin andmax attributes, if given, specify theminimum and maximum possible values for a channel of type integeror decimal. If neither is given, then there is no a prior bound onthe channel values. If one is given, then the channel values arebounded above or below but unbounded in the other direction. Ifboth are given, then all channel values must fall within thespecified range.
Theorientation attribute is applicable to channels ofinteger or decimal type. It gives the meaning of increasing value.For example, whether X increases to the left or the right. Thevalue may be given as "+ve" or "-ve", with "+ve" being thedefault.
TherespectTo attribute specifies the origin for channelsof integer or decimal type. For time channels, this is given as aURI for a<timestamp>
element. For otherapplication defined channels the URI is application-dependent.
Typically, a channel in the<traceFormat>
will map directly to a corresponding channel provided by thedigitizing device, and its values as recorded in the trace datawill be the original channel values recorded by the device.However, for some applications, it may be useful to storenormalized channel values instead, or even to remap the channelsprovided by the digitizing device to different channels in thetrace data. This correspondence between the trace data and thedevice channels is recorded using a<mapping>
element (described in theMappings section)within the<channel>
element. If no mapping isspecified for a channel, it is assumed to be unknown.
<intermittentChannels>
elementThe
The channels OTx, OTy, OA, OE and OR record pen orientationdata. Implementers may choose to use either pen azimuth OA and penelevation OE, or alternatively tilt angles OTx and OTy. The latterare the angles of projections of the pen axis onto the XZ and YZplanes, measured from the vertical. It is often useful to recordthe sine of this angle, rather than the angle itself, as this isusually more useful in calculations involving angles. The<mapping>
element can beemployed to specify an applied sine transformation. While it is notforbidden to use channels from different groups together (i.e. frommore than one of {OA, OE} and {OTx, OTy}), applications will notnormally do this.
The third degree of freedom in orientation is generally definedas the rotation of the pen about its axis. This is potentiallyuseful (in combination with tilt) in application such asillustration or calligraphy, and signature verification.
Figure 2: (a) azimuth and elevation angles, (b)tilt angles
Figure 3: (a) pen orientation decomposition, (b)pen rotation
Figure 2a displays the pen orientation using Azimuth andElevation. The origin of the Azimuth is at the Y-axis. Azimuthincreases anticlockwise up to 360 degrees. The origin of Elevationis located within the XY-plane. Elevation increases up to 90degrees, at which point the pen is perpendicular to theXY-plane.
Figure 2b explains the definition of the Tilt-X and the Tilt-Yangles. For both the origin is along the Z-axis. Tilt-X increasesup to +90 degrees for inclinations along the positive X-axis anddecreases up to -90 degrees for inclinations along the negativeX-axis. Respectively, Tilt-Y is defined for pen inclinations alongthe Y-axis.
Figure 3a displays the pen orientation decomposition asfunctions of Azimuth/Elevation or alternatively as function ofTilt-X/Tilt-Y. Thereby, elevations of the pen which are mapped tothe XZ- and to the YZ- plane lead to Tilt-X and Tilt-Y.
Figure 3b shows the Rotation of the pen along its longitudinalaxis. The departure of a reference mark or meridian on thepen barrel from the nominal 'up' direction which may be constructedby a ray perpendicular to the pen barrel (somewhere not at the tip)and intersecting a pure-Z ray arising from the surface of the penpassing through the tip. This angle is measured in a clockwisedirection when viewing the pen barrel from tail to tip, indegrees.
The channels CR, CG, CB, CC, CM, CY, CK, C and A are defined torecord color and transparency data as captured by an opticaldevice, as generated by software or by other means.
The channels CR, CG, CB provide an additive color model for thecolors red, green and blue. The channels CC, CY, CM, CK provide asubtractive color model for the colors cyan, magenta, yellow andblack. The channel C provides a mechanism to give color as a singlenumerical value in the range #000000..#FFFFFF that encodes thecolors red, green and blue as three octets. While it is notforbidden to use channels from different groups together (i.e. frommore than one of {C}, {CR, CG, CB} and {CC, CY, CM, CK}),applications will not normally do this. The A channel recordstransparency as an integer. The value 0 represents opaque ink andthe maximum permissible value represents complete transparency.
Color channels are intended for use when these values are partof the data itself and hence potentially changing from one sampleto the next. Strokes with constant color may more economically bedescribed with reference to a<brush>
element.
It is legitimate for an application to have an accessibilitymode or alternative rendering mode where the explicit color valuesin the InkML are reinterpreted as other colors for betteraccessibility or suitability of the rendering device. Examples ofthis would be mapping color to black and white for monochromedevices or to high-contrast colors for greater visibility.
Three channels are provided to provide stroke widthinformation.
The channel W is provided for recording stroke width. The valueis in length units and is the diameter of the larger circle thatcan be inscribed within the trace locus. This allows opticaldevices to record measured stroke width and allows applicationsthat generate InkML to specify desired width for rendering.
The channels BW and BH are defined to record the brush width andheight at each point. The meaning of the width and height isdefined by the brush tip shape, as given by a<brushProperty>.
As with the color channels, the width channels are intended foruse when this quantity is part of the data itself and hencepotentially changing from one sample to the next. Strokes withconstant width may more economically be described with reference toa<brush>
element withwidthandheight properties.
The time channel allows for detailed recording of the timinginformation for each sample point within a trace. This can beuseful if the digitizing device has a non-uniform sampling rate,for example, or in cases where duplicate point data is removed forthe sake of compactness.
The time channel can be specified as either a regular orintermittent channel. When specified as a regular channel, thesingle quote prefix can be used to record incremental time betweensuccessive points. Thevalue of the time channel for a given sample point is defined to bethe timestamp of that point in the units and frame of referencespecified by therespectTo attribute of the timechannel that is defined in the associated<traceFormat>
of thetrace.
As with the other predefined channels, the meaning of the integer or decimal values recorded by the time channel in a given trace is defined by the trace's associated
Theunits attribute gives the units of the recorded timevalues, and therespectTo attribute describes the frame ofreference for those recorded values. The value of therespectTo attribute is a reference to a time stamp. If it isnot given, the time channel values are relative to the beginningtimestamps of the individual traces in which they appear.
The following example defines a time channel whose values for agiven point are the relative to the timestamp referred to by#ts1:
<channel name="T" type="integer" units="ms" respectTo="#ts1" />
If no
In addition to the pre-defined channels, user-defined channelsare allowed, although their interpretation is not required byconforming ink markup processors.
When specifying a number of related channels, it is recommendedto use a common prefix. For example, direction-sensitive stylusforce could be named FX, FY, FZ.
User defined channels may be used to describe ink traces innon-Cartesian coordinate systems, using various compressionschemes, or with supplementary information. Channels need notdescribe properties of the digital ink, per se, but may be used toprovide additional information in the ink stream. Forexample, a user defined channels could give information aboutchanging lighting conditions.
The following example defines a<traceFormat>
which reports decimal-valued X andY coordinates for each point, and intermittent boolean values forthe states of two buttons B1 and B2, which have default values of F("false"):
<traceFormat xml:id="xyb1b2"> <channel name="X" type="decimal"> <mapping type="identity"/> </channel> <channel name="Y" type="decimal"> <mapping type="identity"/> </channel> <intermittentChannels> <channel name="B1" type="boolean" default="F"> <mapping type="identity"/> </channel> <channel name="B2" type="boolean" default="F"> <mapping type="identity"/> </channel> </intermittentChannels></traceFormat>
The appearance of a<traceFormat>
element in an InkML file bothdefines the format and installs it as the current format forsubsequent traces except within a<definitions>
block (seeSpecifying Trace Formats). Theidattribute of a<traceFormat>
allows the formatto be reused by multiple contexts (see theContext section). If no<traceFormat>
is specified, the followingdefault format is assumed:
<traceFormat xml:id="DefaultTraceFormat"> <channel name="X" type="decimal"/> <channel name="Y" type="decimal"/></traceFormat>
Thus, in the simplest case, an InkML file may contain nothingbut<trace>
elements within an<ink>
element.
<trace>
elementcontinuation
has values "end" or"middle",Default: none#DefaultContext
," unless this<trace> iscontained within aThe following grammar defines the syntax of the data thatappears within a<trace>
element. It isdescribed using the subset of Extended Backus-Naur Form defined in the Notationsection of theExtensibleMarkup Language (XML) 1.0 (Fourth Edition)specification [EBNF]. This subset of EBNF includes the followingnotation:
The grammar is as follows:
trace ::= point ("," point)* ","? wsp*point ::= (wsp* value)+ wsp*value ::= difference_order? wsp* "-"? wsp* number | "T" | "F" | "*" | "?"number ::= (decimal | double | hex)double ::= decimal ("e"|"E") ("+"|"-")? digit+ decimal ::= digit+ ("." digit*)? | "." digit+hex ::= "#" (digit | "A" | "B" | "C" | "D" | "E" | "F")+difference_order ::= ("!" | "'" | '"')digit ::= ("0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9")wsp ::= (#x20 | #x9 | #xD | #xA)Additionally,wspmay occur anywhere except withinadecimal, float orhex andmust occur ifrequired to separate twovalues. Otherwise the longesttoken is matched. For example, "3245" requires an internalwsp character if it is to be interpreted as two decimalnumbers, "32" and "45". On the other hand, "0.923.45" will beinterpreted as "0.923" and ".45".
The number ofvalue tokens appearing within each pointmust be at least equal to the number of regular channels and be nomore than the number of regular channels plus the number ofintermittent channels.
The<trace>
element is used to record thedata captured by the digitizer. It contains a sequence of pointsencoded according to the specification given by the<traceFormat>
element.
Thetype attribute of a<trace>
indicates the pen contact state (either "penUp
" or"penDown
") during its recording. A value of"indeterminate
" is used if the contact-state isneither pen-up nor pen-down, and may be either unknown or variablewithin the trace. For example, a signature may be captured as asingle indeterminate trace containing both the actual writing andthe trajectory of the pen between strokes. The values of the tip switch state channel "S", if present in the trace, overrides the value of thetype attribute.
If acontinuation
attribute is present, itindicates that the current trace is a continuation trace, i.e. itspoints are a temporally contiguous continuation of (and thus shouldbe connected to) another trace element. The possible values of theattribute are:
begin
: the current trace is the first of the setof continuation tracesend
: the current trace is the last of the set ofcontinuation tracesmiddle
: the current trace is a continuation trace,but is neither the first nor the last in the set of tracesIf the current trace is a continuation trace but is not thefirst trace in the set (i.e. thecontinuation
attribute has valuemiddle
orend
) then apriorRef
attribute must be present and must containthe URI of the trace of which the current trace is a continuation.Abegin
ormiddle
trace can be the priortrace for exactly one trace. Anend
trace cannot bethe prior trace of any other trace.
Regular channels may be reported as explicit values,differences, or second differences: Prefix symbols are used toindicate the interpretation of a value: a preceding exclamationpoint (!
) indicates an explicit value, a single quote('
) indicates a single difference, and a double quoteprefix ("
) indicates a second difference. If there isno prefix, then the channel value is interpreted as explicit,difference, or second difference based on the last prefix for thechannel. If there is no last prefix, the value is interpreted asexplicit.
A second difference encoding must be preceded by a singledifference representation; which, in turn, must be preceded with anexplicit encoding.
All traces must begin with an explicit value, not with a firstor second difference. This is true of continuation traces as well.This allows the location and velocity state information to bediscarded at the end of each trace, simplifying parserdesign. This is true for continuation traces.
Both regular and intermittent channels may be encoded with thewildcard character "*". This wildcard character means either thatthe value of the channel remains at the previous channel value (ifexplicit), or that the channel continues integrating with theprevious velocity or acceleration values, as appropriate.
Intermittent channels may be encoded with the wildcard character"?". This means that a value of a channel is not given at thatpoint. It is useful when there are several independent intermittentchannels, and they do not always report simultaneously, e.g.
<trace> 11 12 9, 21 22 ? T, 31 32, 41 42 5, 51 52 ? F</trace>
Booleans are encoded as "T" or "F".
For each point in the trace, regular channel values are reportedfirst in the order given by the<channel>
elements of the applicable<traceFormat>
. Allregular channels must be reported, if only with the explicitwildcard "*". If any intermittent values are reported for thepoint, they are given next, in the order given by the<intermittentChannels>
elements of theapplicable<traceFormat>
. Unreportedintermittent channels are interpreted as though they were given bythe wildcard "*".
Here is an example of a trace of 11 points, usingthe following traceFormat:
<traceFormat> <channel name="X" type="decimal"/> <channel name="Y" type="decimal"/> <intermittentChannels> <channel name="B1" type="boolean" default="F"/> <channel name="B2" type="boolean" default="F"/> </intermittentChannels></traceFormat><trace xml:id="id4525abc"> 1125 18432,'23'43,"7"-8,3-5,7 -3,6 2,6 8,3 6 T,2 4*T,3 6,3-6 F F</trace>
The trace is interpreted as follows:
Trace | X | Y | vx | vy | B1 | B2 | Comments |
---|---|---|---|---|---|---|---|
1125 18432 | 1125 | 18432 | ? | ? | F | F | button default values |
'23'43 | 1148 | 18475 | 23 | 43 | F | F | velocity values |
"7"-8 | 1178 | 18510 | 30 | 35 | F | F | acceleration Values |
3-5 | 1211 | 18540 | 33 | 30 | F | F | implicit acceleration |
7 -3 | 1251 | 18567 | 40 | 27 | F | F | optional whitespace |
6 2 | 1297 | 18596 | 46 | 29 | F | F | whitespace required |
6 8 | 1349 | 18633 | 52 | 37 | F | F | |
3 6 T | 1404 | 18676 | 55 | 43 | T | F | an optional value |
2 4*T | 1461 | 18723 | 57 | 47 | T | T | wildcard |
3 6 | 1521 | 18776 | 60 | 53 | T | T | optional keep last |
3-6 F F | 1584 | 18823 | 63 | 47 | F | F | optionals |
An ink markup generator might also include additional whitespaceformatting for clarity. The following trace specification isidentical in meaning to the more compact version shown above:
<trace xml:id="id4525abc"> 1125 18432, '23 '43, "7 "-8, 3 -5, 7 -3, 6 2, 6 8, 3 6 T, 2 4 * T, 3 6, 3 -6 F F</trace>
Note: see Appendix BImplementationGuidelines for information about reducing file or streamsize.
InkML provides mechanisms to gather and combine traces intostructured collections via the<traceGroup>
and<traceView>
elements. These allow multipletraces or groups to be treated as single units for the purposes ofreferencing, attaching context information, semantic labeling, orapplication-specific needs. The<traceGroup>
element gathers<trace>
other<traceGroup>
or<traceView>
elements into a unit. The<traceView>
elementrefers to existing<trace>
,<traceGroup>
or other<traceView>
elements to provide alternativeviews or organization on the ink. For example, a diagrammingapplication may record a stream of fixed-length<trace>
packages, organized as continuations,and use<traceGroup>
elements containing<traceView>
elements to record the logicalstructure of the diagram.
<traceGroup>
element#DefaultContext
," unless this<traceGroup> iscontained within anotherThe<traceGroup>
element is used to groupsuccessive traces which share common characteristics, such as thesame<traceFormat>
. The brush and contextsections describe other contextual values that can be specified fora<traceGroup>
. In the following example the twotraces enclosed in the<traceGroup>
share thesame brush (see theBrushes section for adescription of brushes).
<traceGroup brushRef="#penA"> <trace>...</trace> <trace>...</trace></traceGroup>
The<traceGroup>
element may be used forvarious purposes, such as to group traces according to theirproperties at the time of capture or according to computedrecognition results. The element may be nested, and it may be usedas a generic grouping mechanism, e.g. for the semantic labeling oftraces.
Trace groups are the primary mechanism for assigning<context>
to traces in archival ink markup. Foradditional details about this usage, see theArchival Applications section.
<traceView>
element<trace>
,<traceGroup>
or<traceView>
element.<traceView>
element references.<traceView>
element references.The<traceView>
element is used to includetraces by reference from the current document or other documents. Acommon use is to group a collection of<traceView>
elements in a<traceGroup>
to provide annotations.
Together,traceDataRef,fromandto refer to another element and select part ofit. AtraceDataRef attribute may refer to a<trace>
, a<traceGroup>
oranother<traceView>
.
A missingfrom attribute is equivalent toselecting the first point in the (recursively) first child of thereferenced element. A missingto attribute isequivalent to selecting the last point in the (recursively) lastchild of the referenced element. With these defaults, the<traceView>
selects the portion of thereferenced element from the first point to the last point,inclusive. If neither ato norfrom attribute is given, this implies the entirereferenced element is selected.
Any value of afrom ortoattribute is a colon-separated list of integers, whose meaning isdefined as follows: An empty list of integers selects the entirereferenced object (point,<trace>
,<traceGroup>
or<traceView>
).If the list is non-empty, then its first element is taken as a1-based index into the referenced object, and the remaining list isused to select within the object. It is an error to try to selectwithin a single point. The rationale to allow selection using thiscolon-separated-integer indexing scheme is that the desired inkselections in a referenced document might not have id attributes onthe desired nodes.
If the referenced object is a<traceView>
,then the indexing is relative to the tree selected by the<traceView>
, not relative to the originalobject.
If a<traceGroup>
contains continuationtraces, they are counted independently.
Suppose we have the following ink element:
<ink xmlns="http://www.w3.org/2003/InkML"> <trace xml:id="L1">911 912, 921 922, 931 932</trace> <traceGroup xml:id="L2"> <trace>111 112, 121 122</trace> <traceGroup xml:id="L2-Larry"> <trace>221 212, 221 222</trace> <trace>311 312, 321 322</trace> </traceGroup> <trace>411 412, 421 422</trace> <traceGroup> <traceGroup> <trace xml:id="L2-Moe">521 512, 521 522</trace> <trace>611 612, 621 622</trace> </traceGroup> </traceGroup> <trace>711 712, 721 722</trace> </traceGroup> <traceGroup xml:id="L3"> <traceView traceDataRef="#L1" from="2"/> <traceView traceDataRef="#L2" from="2" to="4:1:1"/> </traceGroup> <traceView xml:id="L4" traceDataRef="#L3" from="1:2" to="2:1:2:1"/></ink>
WithtraceDataRef "#L1", thefrom index"2" refers to the point (921, 922). WithtraceDataRef "#L2", thefrom index "2"refers to the<traceGroup>
with id "L2-Larry",the index "4:1:1" refers to the element with id "L2-Moe", the index"4:1:1:2" refers to the point (521, 522), and the index "4:1:1:2:1"is illegal.
The<traceGroup>
with id "L3" selects thefollowing structure
<traceGroup> <trace>921 922, 931 932</trace> <traceGroup> <traceGroup> <trace>221 212, 221 222</trace> <trace>311 312, 321 322</trace> </traceGroup> <trace>411 412, 421 422</trace> <traceGroup> <traceGroup> <trace>521 512, 521 522</trace> </traceGroup> </traceGroup> </traceGroup></traceGroup>and the
<traceView>
with id "L4" selects<traceGroup> <trace>931 932</trace> <traceGroup> <traceGroup> <trace>221 212, 221 222</trace> <trace>311 312</trace> </traceGroup> </traceGroup></traceGroup>
The context in which ink is written and recorded comprises manydetails. Examples include the size of the surface the traces wererecorded on, the pen tip used or the accuracy of the pressuremeasurements. This contextual information needs to be captured byInkML in order to fully characterize the recorded ink data. Thissection defines markup that provides a way to describe thisinformation, including the<context>
elementwhich provides a means to associate a defined context with tracedata.
The format of trace data -- both in the channels available andtheir particulars -- may vary from device to device, including fromstylus to stylus with the same tablet. Therefore, the<context>
element may refer to or contain aspecific<traceFormat>
and<inkSource>
elementfor the device.
As the ink is generated, there may be various context-dependentattributes associated with the pen. For this, a<brush>
element may beused to record the attributes of the pen during the capture of thedigital ink.
The start times of traces are often given relative to aspecified point in time. A context may provide a<timestamp>
element forthis.
For applications that require the sharing of ink, contexts mayrelate their ink to a shared canvas, given by a<canvas>
element. Thetrace format of the ink source is related to the trace format of ashared canvas by means of a<canvasTransform>
element.
<context>
elementThis section describes the<context>
elementand its attributes. The context element both provides access to auseful shared context (canvas) and serves as a convenientagglomeration of contextual attributes. It is used by the<traceGroup>
and<traceView>
elements to define the complete shared context of a group of tracesor may be referred to as part of a context change in streamingmode. In either mode, individual attributes may be overridden attime of use. Additionally, individual traces may refer to apreviously defined context (again optionally overriding itsattributes) to describe a context change that persists only for theduration of that trace.
Although the use of the<context>
element andattributes is strongly encouraged, default interpretations areprovided so that they are not required in an InkML file if alltrace data is recorded in the same virtual coordinate system, andits relationship to device coordinates is either not needed orunknown.
The<context>
element consolidates allsalient characteristics of one or more ink traces. It may bespecified by declaring all non-default attributes, or by referringto a previously defined context and overriding specific attributes.The element is found either in the<definitions>
element or as a child of the<ink>
element inStreaming InkML
Each constituent part of a context may be provided either by areferencing attribute or as a child element. If both are given,then the child element is used. Thus it is possible to have eitheratraceFormatRef attribute or a<traceFormat>
child element. If both are given,then the<traceFormat>
child is used and theattribute is ignored.
One of the important requirements for the ink format is to allowaccurate recording of metadata about the format and quality of inkas it is reported by the source. The source is typically hardwareas embodied in a digitizer device, but may in general be any"virtual" source of ink, such as a software application that istracking the trajectory of an object. This is accomplished in the<inkSource>
element, which supports capture ofbasic information about the make and model of the device and theink channels captured, as well as very detailed information about anumber of source characteristics.
Some of these characteristics are already commonly used indigitizer specifications, while others are somewhat more esoteric,but nonetheless potentially very useful. In general, these sourcecharacteristics describe signal fidelity, allow understanding ofthe quality of the data, and impose some limits on how the data canbe used. They are not intended to be used for repair of bad datafrom the source.
<inkSource>
element<inkSource>
element.<inkSource xml:id="mytablet" manufacturer="Example.com" model="ExampleTab 2000 USB" specificationRef="http://www.example.com/products/exampletab/2000usb.html"> <traceFormat> <channel name="X" ... /> <channel name="Y" ... /> <channel name="F" ... /> </traceFormat> <sampleRate uniform="true" value="200"/> <latency value="50"/> <activeArea size="A6" height="100" width="130" units="mm"/> <sourceProperty name="weight" value="100" units="g"/> <channelProperties> <channelProperty channel="X" name="resolution" value="5000" units="1/in"/> <channelProperty channel="Y" name="resolution" value="5000" units="1/in"/> <channelProperty channel="Y" name="peakRate" value="50" units="cm/s"/> <channelProperty channel="F" name="resolution" value="1024" units="dev"/> </channelProperties></inkSource>
The<inkSource>
element will allowspecification of:
<sampleRate>
elementThe<sampleRate>
element captures the rate atwhich ink samples are reported by the ink source. Many devicesreport at a uniform rate; other devices may skip duplicate pointsor report samples only when there is a change in direction. This isindicated using theuniform
attribute, which must bedesignated "false" (non-uniform) ifany pen-down points areskipped or if the sampling is irregular.
A time channel should be used to get time information when thesampling rate is not uniform. When the sampling rate is notuniform, thevalueattribute of the<sampleRate>
element specifiesthe maximum sampling rate.
<sampleRate uniform="true" value="200"/>
<latency>
elementThe<latency>
element captures the basicdevice latency that applies to all channels, in milliseconds, fromphysical action to the API time stamp. This is specified at thedevice level, since all channels often are subject to a commonprocessing and communications latency.
<latency value="50"/>
<activeArea>
elementMany ink capture devices have a notion of active area, whichdescribes the two-dimensional area within which the device iscapable of sensing the pen position. This element allows thespecification of a rectangular active area.
<activeArea size="A6" height="100" width="130" units="mm"/>
<sourceProperty>
elementThe<sourceProperty>
element provides asimple mechanism for the capture of additionalnumeric orstring properties of the ink source as awhole.
<sourceProperty name="weight" value="100" units="g"/>
<channelProperties>
elementThe<channelProperties>
element is meant fordescribing properties of specific channels reported by the inksource. Properties such as range and resolution may be specifiedusing corresponding elements. For more esoteric properties (from alay user's standpoint) the generic
<channelProperties> <channelProperty channel="X" name="resolution" value="5000" units="1/in"/> <channelProperty channel="Y" name="resolution" value="5000" units="1/in"/> <channelProperty channel="Y" name="peakRate" value="50" units="cm/s"> <channelProperty channel="F" name="resolution" value="1024" units="dev"/></channelProperties>
<channelProperty>
elementThe<channelProperty>
element provides asimple mechanism for the capture of additionalnumeric orstring properties of specific channels when knownand appropriate. The following channel property names, with theirspecified meanings, are reserved. Other properties may be definedby the user.
Property name | Interpretation |
---|---|
threshold | Threshold - e.g. for a binary channel,the threshold force at which the tip switch is activated |
resolution | Resolution - the scale of the valuesrecorded. This may be expressed as fractions of a unit, e.g. 1/1000in (inches), 0.1mm, 1deg (degrees). Itmay also be expressed, more popularly, in inverse units, e.g."1000 points per inch" would be given as 1000 in units1/in. |
quantization | Quantization - the unit of smallestchange in the reported values. If the value is reported as integer,this is assumed to be the same as the resolution. Note that ifdecimal values are recorded for resolution, the quantization of thedata may be smaller than the "resolution". |
noise | Noise - the RMS value of noisetypically observed on the channel. This is distinct from accuracy!It is an indication of the difference observed in the data from thedevice when the same path is traced out multiple times (e.g. by arobot). |
accuracy | Accuracy - the typical accuracy of thedata on the channel (e.g. "0.5 mm", "10 degrees" or "0.1 Newton")This is the typical difference between the reported position andthe actual position of the pen tip (or tilt ...) |
crossCoupling | Cross-coupling - the distortion in thedata from one channel due to changes in another channel. Forexample, the X and Y coordinates in an electromagnetic digitizerare influenced by the tilt of the pen. This would be specified bydX/dOTx = ... or max delta X vs. OTx = ... If the influencingchannels are also recorded, and the cross-couplings are accuratelyspecified, it may be possible to compensate for the cross-couplingby subtracting the influence, at the expense of higher noise. Thecross-coupling is always expressed in the units of the twochannels, e.g. if X mm and OTx is in degrees, then cross-couplingis in mm/deg. |
skew | Skew - the temporal skew of thischannel relative to the basic device latency, if any. For example,some devices actually sample X and Y at different points in time,so one might have a skew of -5 millisecond, and the other +5millisecond. |
minBandwidth | Minimum bandwidth (in Hz) - the minimumbandwidth of the channel, in Hz (not samples/second), i.e., thefrequency of input motion up to which the signal is accurate towithin 3dB. |
peakRate | Peak rate - the maximum speed at whichthe device can accurately track motion |
distortion | Dynamic distortion, e.g., how velocityaffects position accuracy. This is expressed in inverse seconds,e.g. 0.01 mm / mm / s. This kind of distortion is often crosschannel, but this specification only allows a generic,channel-specific value. |
<channelProperty channel="F" name="threshold" value="0.1" units="N"/><channelProperty channel="X" name="quantization" value="0.01" units="mm"/>
Along with trace data, it is often necessary to record certainattributes of the pen during ink capture. For example, in a notetaking application, it is important to be able to distinguishbetween traces captured while writing as opposed to those whichrepresent erasures. Because these attributes will often beapplication specific, this specification does not attempt toenumerate all the brush attributes which can be associated with atrace. It provides a syntax for specifying brush property names,units and values. Some common brush property names aredefined by the specification. But applications may defineother named properties not explicitly named in the specificationsince it is possible to imagine attributes which are describedusing complex functions parameterized by time, pen-tip force, orother factors. The specification allows for capturing the fact thata given trace was recorded in a particular brush context, leavingthe details of precisely defining specific attributes of thatcontext (such as complex brush geometries and colors in non-RGBcolor spaces) to a higher-level, application specific layer.
Depending on the application, brush attributes may changefrequently. Accordingly, there should be a concise mechanism toassign the attributes for an individual trace. On the other hand,it is likely that many traces will be recorded using the same setsof attributes; therefore, it should not be necessary to explicitlystate the attributes of every trace (again, for reasons ofconciseness). Furthermore, it should be possible to define entitieswhich encompass these attribute sets and refer to them rather thanlisting the entire set each time. Since many attribute sets will besimilar to one another, it should also be possible to inheritattributes from a prior set while overriding some of the attributesin the set.
<brush>
elementIn the ink markup, brush attributes are described by the<brush>
element. This element allows for thedefinition of reusable sets of brush attributes which may beassociated with traces. For reference purposes, a brush specifiesan identifier which can be used to refer to the brush. A brush caninherit the attributes of another<brush>
element by including a brushRef attribute which contains the id ofthe referenced brush. The brush attributes are stored in<brushProperty>
child elements. Brushes may beused to convey information about how a stroke is to be rendered orsimply to distinguish between different types of traces (e.g. aneraser vs. a pen, different writers). In this later case, all thatmatters is that brushes are distinct so no brush properties arenecessary.
Brush attributes are associated with traces using the brushRefattribute. When it appears as an attribute of an individual<trace>
, the brushRef specifies the brushattributes for that trace. When it appears as an attribute of a<traceGroup>
element, the brushRef specifies thecommon brush attributes for all traces enclosed in the<traceGroup>
. Within the<traceGroup>
, an individual trace may stilloverride the traceGroup's brush attributes using a brushRefattribute.
Brush attributes can also be associated with a context byincluding the brushRef attribute on a<context>
element. Any traces which reference the context using a contextRefattribute are assigned the brush attributes defined by the context.If a trace includes both brushRef and contextRef attributes, thebrushRef overrides any brush attributes given by thecontextRef.
The default brush may be explicitly specified using the URI"#DefaultBrush
". The id "DefaultBrush
" is therefore reserved and may not be used as the id of a user defined<brush>
element. The default brush is identical to a user defined brush that has not explicit<brushProperty>
child elements.
In streaming ink markup, brushes are assigned to a traceaccording to the current brush, which can be set using the<context>
and<brush>
elements. See sectionStreamingApplications for a detailed description of streaming mode.
<brushProperty>
elementThe<brushProperty>
element provides amechanism for the storage of named properties of brushes. Thefollowing brush property names, with their specified meanings, arereserved. Other properties may be defined by the user.
Property name | Interpretation | ||||||
---|---|---|---|---|---|---|---|
width | Width of the brush. If the width property is not given and a BW channel is present,the values of the BW channel are used as the brush width. The default value is defined by the application. | ||||||
height | Height of the brush. If a height property is not given and a BH channel is present, thevalues of the BH channel are used as the brush height. The default value is defined by the application. | ||||||
color | Color of brush as three octets forRGB. If a color property is not given and color channels are present (Cor CR, CG, CB or CC, CM, CY, CK), their values are used for thecolor. Default is #000000. | ||||||
transparency | Transparency of brush as an integer: 0is opaque. If a transparency property is not given and the transparencychannel (A) is present, its value is used. Default is 0. | ||||||
tip | The type of pen tip:ellipse,rectangle, ordrop. Ifellipse, then the width property specifies thehorizontal diameter, and the height property specifies the verticaldiameter. If the height property is absent, its default valueis the value of width. Ifrectangle, the width and height propertiesspecify the width and height of the rectangle. If the heightproperty is absent, the default value is the value of width makingthe brush a square. Ifdrop, the shape is defined by a circleand two tangent lines to a point outside the circle, locatedabove the circle on the vertical axis, as shown inF Default isellipse. If the OR channel is present, the tip shape is rotatedcounter-clockwise by this amount about its origin. | ||||||
rasterOp | A value that defines how the colors ofthe pen and background interact. In the example images below,the original background is white with the black text 'abc' and itis overwritten with a single curved yellow ink stroke.
The default value iscopyPen, which indicates thatthe current pen color is used. Applications may defineadditional rasterOp values. | ||||||
antiAliased | The drawn ink is anti-aliased. Default is true. | ||||||
fitToCurve | The ink is rendered as a series of curves versus aslines between pen sample points. Default is false. | ||||||
ignorePressure | If true, pressure from the pen tip is ignored andthe width of the ink remains the same regardless of the pressure ofthe pen on the tablet surface. If false, the width of the ink gets wider with increased pressureof the pen on the tablet surface. Default is false. |
<brushProperty name="width" value="2" units="cm"/><brushProperty name="color" value="#FF0000"/>
Timestamping of traces is supported by the<timestamp>
element and thetimestampRef,timeOffset andduration attributes of the<trace>
element. For ease of processing, alltimestamps are expressed in milliseconds. Finer-grained timestampsare obtained using fractional values.
<timestamp>
elementThe<timestamp>
element establishes areference timestamp which can then be used for relativetimestamping of traces.
At most one of the attributestime,timestampRefortimeString is used. The time thus given, plus the valueof the attributetimeOffset, gives the time value of thetimestamp.
If more than one oftime,timeString andtimestampRef are given, thentime is used if present.Failing that,timeString is used.
If none oftime,timestampRef ortimeStringare given, then the timestamp refers to some unspecified moment intime. This is useful when the timestamp is referenced by multipleelements to provide relative timing information.
The four examples below illustrate the establishment of variousreference timestamps. The first<timestamp>
element, ts001, refers to January 2, 2004 at 7:00am, UTC. Thesecond establishes timestamp ts002 which refers to January 2, 2004at 7:10am, UTC (10 minutes after the reference timestamp ts001),and the third time stamp, ts003, gives the same time using thetimeString attribute. The fourth creates ts004 with timeJanuary 2, 2004 at 7:10:04.32, UTC (4.32 seconds after thetimestamp of trace ts002).
<timestamp xml:id="ts001" time="1073026800000"/><timestamp xml:id="ts002" timeOffset="600000" timestampRef="#ts001"/><timestamp xml:id="ts003" timeString="2004-01-02T07:10:00Z"/><timestamp xml:id="ts004" timeOffset="4320" timestampRef="#ts002"/>
Ink traces may specify their contexts explicitly, using acontextRef attribute, or implicitly, in which case they usea default context.
Explicitly referenced<context>
elements mayoccur in a<definitions>
element, elsewhere inthe same document or in other documents. Explicit contexts aretypically used in archival ink applications.
Traces that do not make explicit reference to a context occur ina default context. This is established by the sequence of elementsin the<ink>
element. Initially the defaultcontext is empty and uses defaults for all properties, including adefault trace format, default canvas, etc. Then, interspersed withink data, other elements may occur that alter the default context.These elements are<brush>
,<context>
,<traceFormat>
,<inkSource>
and<timestamp>
.As the ink is processed from the first child onward, whenever oneof these elements is encountered, it is installed as the default tobe used by traces. These are used by traces that do not otherwisespecify these properties.
The default context may be explicitly specified using the URI"#DefaultContext
". The id "DefaultContext
" is therefore reserved and may not be used as the id of a user defined<context>
element.
To describe how contextual information is determined, we startwith the notions of "fully resolved context" and "current context"as follows.
Afully resolved context is one for which all the contextinformation (brush, canvas, canvasTransform, inkSource, timestamp,traceFormat) has been obtained either from direct children, byreferences or inherited. Values are obtained for the contextinformation by giving the contents of the<context>
priority over specific references(brushRef,canvasRef,canvasTransformRef,inkSourceRef,timestampRef,traceFormatRef),which take priority overcontextRef, which takes priorityover the current context.
Thecurrent context is a syntactic notion associated toeach node in an ink document. Roughly speaking, the current contextis changed only by<context>
elements that occurdirectly as children to the<ink>
element (i.e.not inside<definitions>
). It is defined asfollows.
<ink>
element has the default context its current context.<ink>
element hasa<context>
element as its previous sibling,then that context fully resolved is the child's currentcontext.<definitions>
elementhave the default context as their current context.The current context is central to streaming ink applications(seeStreaming).
We can now describe how contextual information is determined forink traces.
<trace>
,<traceGroup>
or<traceView>
element (i.e. on that occurs as a direct child of an<ink>
element), a specific reference(brushRef) takes priority overcontextRef which takespriority over the current context. The resulting anonymous contextis the context of this node.<trace>
,<traceGroup>
or<traceView>
elements, a specific reference (brushRef) takes priorityovercontextRef which takes priority over the enclosing<traceGroup>
or<traceView>
node's context which takes priority over the current context. Theresulting anonymous context is the context of this node.InkML provides support for applications that are required tocombine ink from multiple sources. This may arise, for example,from real-time collaboration among several devices, from multipleink annotations on the same base document or multiple pensoperating on the same surface. To support these applications, InkMLuses the concept of a shared space, called acanvas.
A canvas is specified using a<canvas>
element, and is typically referred to by one or more<context>
elements. These contexts may each havetheir own set of ink capture characteristics and trace formats. Inorder to map traces from a particular context to a canvas, and viceversa, each context provides its own canvas transform, inversetransform or both.
A context neither referencing nor inheriting a canvas uses adefault canvas, sufficient to allow simple single-canvas sharingwithout further action on the part of devices or applications.
Each canvas defines its dimensions by giving a<traceFormat>
element. Its channel declarationsmay specify minimum and/or maximum values, an orientation andunits. If no minimum or maximum is given for a channel of integeror decimal type, then it is unbounded in that direction.
If a canvas is bounded in any direction, then all traces definedon that canvas must be contained inside its limits. There may beapplications where strokes appear outside of the canvas. In thesecases the processing of out-of-bounds traces is not defined by thespecification.
Although canvases are virtual spaces, each of the coordinatesmay be assigned a unit of measure. This allows collaboratingparties to establish a common notion of scale.
An example use for such a shared canvas might be a single inkmarkup stream or file that contains traces captured on a tabletcomputer, a PDA device, and an opaque graphics tablet attached to adesktop computer. The size of these traces on each ink source andcorresponding display might differ, yet it may be necessary torelate these traces to one another. They could represent scribbleson a shared electronic whiteboard, annotations of a commondocument, or the markings of two players in a distributedtic-tac-toe game.
The trace data for these different ink sessions could berecorded using the same set of virtual coordinates; however, it isoften useful, and may even be necessary at times, to record thedata in the ink source coordinates, in order to more preciselyrepresent the original capture conditions, for compactness, or toavoid round-off errors that might be associated with the use of acommon coordinate system. Thus we define the concept of a "canvastransform", which can vary according to the ink source. The defaulttransform is the identity. It is also possible to specify themapping from the canvas back to the coordinates of the originaltrace format. This is useful in collaborative ink applicationswhere ink added to the canvas from one source must be interpretedin the frame of reference of the other sources. It is not alwaysnecessary to specify the inverse transform. If the canvas transformis given as an affine map of full rank, then it may be invertednumerically. Likewise if coordinates are transformed by a lookuptable with linear interpolation, then the mapping may be invertednumerically. In all other cases the inverse transformation must beprovided if the inverse mapping is required.
<canvas>
elementThe<canvas>
element provides the virtualcoordinate system, which uniquely identifies a shared virtual spacefor cooperation of ink applications. Together with thetrace-to-canvas coordinate transform (discussed below), it providesa common frame of reference for ink collected in multiple sessionson different devices.
<traceFormat>
element.A<canvas>
element must have an associated<traceFormat>
, which may either be given as achild element or referred to by atraceFormatRef attribute. Ifboth a
Example:
<canvas xml:id="A4PaperCanvas"> <traceFormat> <channel name="X" type="decimal" min="0" max="210" units="mm"/> <channel name="Y" type="decimal" min="0" max="297" units="mm"/> </traceFormat></canvas>
<canvasTransform>
elementThe<canvasTransform>
element is used torelate two coordinate systems. The source and target coordinatesystems are ultimately defined in terms of<traceFormat>
elements. These trace formats mayeither be given directly, or indirectly by<inkSource>
,<context>
orother<canvas>
elements. In general, the sourceand target coordinate systems may involve a different number andtype of coordinates, or have different ranges and orientation forthe same dimension.
The contents of the<canvasTransform>
consists of one or two<mapping>
elements.If there is only one, then it is the mapping from the source to thetarget coordinate system, where the meaning of "source" and"target" is determined by the use. If there are two children, thefirst is the mapping from the source to the target and the secondis the inverse mapping from the target back to the source.
The transform and its inverse need not be full inverses in themathematical sense. If a transform is from a trace format to acanvas with fewer coordinates, then the inverse transform may mapfrom the canvas back to the original trace format by supplyingdefault values for the coordinates not in the canvas. This wouldoccur, for example, if a party were sharing ink from a device witha force channel with a canvas with only spatial coordinates.
For certain classes of mappings, the inverse mapping may bedetermined automatically. These are mappings of type "identity","affine" (for matrices of full rank), "table" (univariate, withlinear interpolation), and "product" mappings of these. In thiscase, it is possible to specify that an inverse should bedetermined automatically by giving only the forward transform andspecifying a value oftrue
for theinvertibleattribute. If two<mapping>
elements arespecified, then theinvertible attribute isignored.
For an application to give only the inverse transform, it shouldsupply the forward transform as an unknown mapping:
<canvasTransform> <mapping type="unknown"/> <mapping mappingRef="#map001"/></canvasTransform>
The default canvas has two real-valued coordinates X and Y, bothunbounded in the positive and negative directions. More precisely,the default canvas is made available as though the followingelement were included in each InkML document:
<canvas xml:id="DefaultCanvas"> <traceFormat> <channel name="X" type="decimal" default="0" orientation="+ve" units="em"/> <channel name="Y" type="decimal" default="0" orientation="+ve" units="em"/> </traceFormat></canvas>
The default canvas may be explicitly specified using the URI"#DefaultCanvas
". The id "DefaultCanvas
" is therefore reserved and may not be used as the id of a user defined<canvas>
element.
This section describes components of the ink markup which areapplicable to multiple aspects of the ink markup.
The<mapping>
element provides a uniformsyntax for the various uses of mappings in the ink markup. Theelement has anid attribute, which allows a particularmapping to be applied in multiple places. When a previously definedmapping is reused, themappingRef attribute is used to referto the<mapping>
element, which might be definedin a<definitions>
block. Mappings appear in thefollowing different places in InkML:
<channel>
element of a<traceFormat>
, the<mapping>
element is used to describe the transformation from the valuesactually produced by the device to the values recorded in the tracedata.<canvasTransform>
, a mapping maybe used to specify the forward or inverse transformations betweenan ink source and a canvas coordinate system.InkML supports several types of mappings: unknown, identity,lookup table, affine map, formula (specified using a subset ofMathML [MATHML2]) and cross product. The mapping type is indicated by thetype attribute of a<mapping>
element.Note: If no mapping appears for a<channel>
, itdefaults to "unknown", which is safer than assuming that 'X' isidentical to the device's 'X' since some filtering or modificationscould have been applied. Furthermore, one can specify whether theresults of a mapping expression are absolute or relative to thecurrent data value. This is done by means of theapplyattribute. For lookup table mappings in particular, one candetermine how to interpret intermediate mapping values. This isspecified using theinterpolation attribute.
Some points may have channel values that cannot be mapped. These may lie outside the domain of a MathML mapping (e.g. division by zero, arcsine of 7) or outside the scope of a lookup table (e.g. below the lowest value when the interpolation scheme is other than "ceiling"). In this situation the behavior is not specified and may vary from implementation to implementation. For example, an implementation may choose to raise an error or omit the points.
<mapping>
element(The mathml prefix above is declared as"http://www.w3.org/1998/Math/MathML", the MathML schemanamespace [MATHML2].)
If thetype attribute has valueidentity then the element is empty.
Identity mappings are specified using an empty mappingelement:
<mapping xml:id="m01" type="identity" /><channel name="X" type="decimal" units="pt" default="0"> <mapping type="identity"/> </channel>
They are used, for example, to define a<traceFormat>
channel that reports the exactdata that is recorded by a corresponding device channel, with nofiltering or transformation.
If thetype attribute has valueproduct then the contents is a set of<mapping>
elements, each giving values for oneor more of the coordinates. This allows a multivariate mapping tocompute the different coordinate results according to the mostconvenient means. For example, spatial coordinates may betransformed using an affine map, button states by lookup tables,and color coordinates using formulas.
If thetype attribute has valuetable then the mapping is a function specified bya lookup table given as a<table>
elementcontaining rows of values separated by commas.
If thetype attribute has valueaffine then the content is an<affine>
element specifying an affinetransformation (u ↦M u +b) fromn source values tom target values. All of the sourceand target values must be of the same type, either integer or real(decimal or float). A matrixM containing only the values 0,1 and -1 may be used to perform arbitrary permutation andreflection of coordinates. If the affine map computes a real numberfor an integer coordinate, then the value is rounded to the nearestinteger.
If thetype attribute has valuemathml then the content is a subset of MathML [MATHML2]restricted to the following subset of Content MathML 2.0elements:
<bind>
element.Operator qualifiers:degree, logbase
This is a subset has been selected to provide expressionssuitable for scalar functions on integers, real numbers and booleanvalues. A number of restrictions apply:
<mathml:math>
element are those in the abovelist.<ci>
and<cn>
elements is restricted to be text. Inparticular, Presentation MathML markup is not allowed.<cn>
element. Thetypeattribute may take the valuesinteger,real orrational. Other attributes may begiven on elements, but they are ignored.<apply>
element.The content of The arithmetic operators return values whose typedepends on the type of the arguments. The logical operators andrelations return boolean values. The elementary functions returnreal values.
Example: The following mapping converts from polar torectangular coordinates.
<mapping type="product"> <mapping type="mathml"> <bind/> <bind source="VR" variable="r"/> <bind source="VTh" variable="theta"/> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci>r</ci> <apply> <cos/> <ci>theta</ci> </apply> </apply> </math> </mapping> <mapping type="mathml"> <bind/> <bind source="VR" variable="r"/> <bind source="VTh" variable="theta"/> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci>r</ci> <apply> <sin/> <ci>theta</ci> </apply> </apply> </math> </mapping></mapping>
<bind>
elementThe<bind>
element is provided for bindingchannels to entities (variable names, lookup table columns) withina mapping, and thus it supports the reuse of predefined mappings.For each type of mapping, the relevant bindings can be expressed bythe combined usage of the<bind>
element'sattributes, which aresource,target,columnandvariable.
For an identity mapping (type="identity"), if the sourcechannel has a different name than the channel being defined, thiscan be specified using a<bind>
element with asource attribute. In the following markup, the<traceFormat>
channel X contains unmanipulateddata from the device's devX channel. When the mappingtype is an identity mapping, the<bind>
elementsource attribute is required, and the otherattributestarget,column, andvariable must not be present.
<channel name="X"> <mapping type="identity"> <bind source="devX"/> </mapping></channel>
Within a mapping formula (type="mathml"), the variablenames in the formula need to be bound to particular channel names.This is specified using a combination ofsource andvariable attributes for binding inputs of the formula, andtarget andvariable for the output of the formula.This is useful if the same mapping formula is to be reused acrossmultiple channels, like X and Y for example. When the mappingtype is an mathml mapping thecolumn attribute forthe<bind>
element must not be present.
<mapping xml:id="m06" type="mathml"> <bind variable="Q" /> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <plus/> <ci>Q</ci> <cn>10</cn> </apply> </math></mapping>
The example shown above means that the channel X is referred toby the variable name Q in the mapping expression "Q+10".
For a lookup table (type="table"), each index column mustbe bound to the channel that provides the input for the lookupoperation. This is done with a<bind>
elementthat specifiessource andcolumn attributes.Similarly, each value column must be bound to the channel thatreceives the output of the lookup. Its<bind>
element specifiestarget andcolumn. Whenthe mapping type is a lookup mapping thevariableattribute for the<bind>
element must not bepresent.
The following example indicates assignments of channels tocolumns. It means that values for the channels OTx and P are usedto look up the value of the cross-coupling for channel X in thetable given by the mapping below:
<mapping xml:id="m07" type="table"> <bind column="1"/> <bind source="OTx" column="2"/> <bind source="P" column="3"/> <table apply="relative" interpolation="floor"> 10 45 512, 9 45 400, 8 45 372, 7 45 418, 10 50 510, 9 50 403, 8 50 302, 7 50 407, 10 55 512, 9 55 410, 8 55 303, 7 55 405, 10 60 512, 9 60 420, 8 60 355, 7 60 401, </table></mapping>
For an affine mapping (type="affine"), the column values give the meaning of the rows and columns of the transformation matrix. Suppose an affine mapping is specified by the augmented matrix (M b), corresponding to the transformation v = M . u + b. Then a<bind>
element with asource attribute will have acolumn attribute specifying which index in the vector u corresponds to the named sourcechannel. Likewise, a<bind>
element with atarget attribute will have acolumn attribute specifying which index in the vector vcorresponds to the named target channel. If the target bindings arethe same as the source bindings, then they may be omitted.
<table>
elementtable
element.wherenumber is defined by the grammar given in the<trace> elementsection.
The<table>
gives a set of points for amapping. The points are given as comma-separated rows. Each rowmust have the same number of entries. The final row may optionallybe followed by a comma. Each row in the table represents a value ofthe function at one point. Which columns represent the argument(s)and which the result(s) is determined by<bind>
elements.
The entries in the table may either be all numerical or allboolean. They may be derived empirically, by measuring propertiesof a device, calculated to provide efficient approximation to anumerical function, or give an exhaustive enumeration of values ofa function over a finite set of values.
Example:
The following example means that X is a function of OE, given bya lookup table. The value "relative" for theapply, meansthe table gives an amount to increase X.
<channel name="X"...> ... <mapping xml:id="m03" type="table"> <bind source="OE"/> <bind/> <table apply="relative" interpolation="floor"> 45 10, 50 9, 55 8, 60 7 </table> </mapping> ...</channel>
Tables may have more than two columns, with some of them (thesource columns) determining others (the target columns). If thereis more than one source column, then all possible combinations ofsource values must be given. For example, if there are two sourcecolumns with one having 3 distinct values and the other having 5distinct values, then the table must have 15 rows.
The value of theinterpolation attribute defines thebehavior for indices that don't appear in a numerical table. Thefollowing summarizes the behavior of the above table for thevarious values ofinterpolation:
"floor" | The value is determined by rounding all source variables downto the nearest specified value.X += 10 if 45 ≤ OE < 50,X += 9 if 50 ≤ OE < 55,... |
---|---|
"middle" | The value is constant on regions whose boundaries are mid-waybetween the given source values.X += 10 if 45 ≤ OE < 47.5,X += 9 if 47.5 ≤ OE < 52.5,... |
"ceiling" | The value is determined by rounding all source variables up tothe nearest specified value.X += 10 if OE ≤ 45,X += 9 if 45 < OE ≤ 50,... |
"linear" | Piece-wise linear interpolation. |
"cubic" | Interpolation by cubic splines. This option may be used onlyfor univariate mappings and requires the table have at least 4points. |
Theinterpolation attribute may not be used with booleantables.
<affine>
element<affine>
element.( number+ ",")* number*
wherenumber is defined by the grammar given in the<trace> elementsection.
The<affine>
element provides the entries foran affine mapping fromn source values tom targetvalues. An affine mapping consists of a linear transformation(multiplication by a matrix) and a shift (adding a vector). Thecontent of the<affine>
element is text giving am comma-separated rows ofn+1 numbers each. The finalrow may optionally be followed by a comma. The firstncolumns specify anm ×n matrixM, and the last columngives a vectorb of lengthm. Ifu is thesource vector ofn coordinates, thenv = M u +b is the target vector ofm coordinates.
The following is an example of an affine mapping using an<affine>
element to describe the transform (X,Y) ↦ (-Y, X+200).
<mapping xml:id="m01" type="affine"> <bind source="X" column="1"/> <bind source="Y" column="2"/> <affine> 0 -1 0, 1 0 200, </affine></mapping>
<definitions>
elementThe<definitions>
element is a containerwhich is used to define reusable content. The definitions within a<definitions>
block can be referenced by otherelements using the appropriate syntax. Content within a<definitions>
block has no impact on theinterpretation of traces, unless referenced from outside the<definitions>
block. In order to allow them tobe referenced, elements within a<definitions>
block must include anid; attribute. Therefore, an elementwhich is defined inside a<definitions>
withoutanid, or that is never referenced, serves no purpose.
One of the primary uses of<definitions>
isto define contextual information. In particular, the elements<brush>
,<canvas>
,<canvasTransform>
,<context>
,<inkSource>
,<mapping>
,<timestamp>
and<traceFormat>
may be given inside a<definitions>
. These maybe referenced from other elements by the attributesbrushRef,canvasRef,canvasTransformRef,contextRef,inkSourceRef,mappingRef,timestampRef andtraceFormatRef, respectively.Timestamps may also be referenced by therespectTo attributeof the<channel>
element.
Another use of<definitions>
is to definedigital ink traces for later reference. These may be given by<trace>
,<traceGroup>
or<traceView>
. These are not considered part ofthe ink data to be handled by the application until they arereferenced from other elements (outside the<definitions>
) by atraceDataRefattribute. This is useful in archival applications.
The following simple example illustrates usage of the<definitions>
element.
<ink xmlns="http://www.w3.org/2003/InkML"> <definitions> <brush xml:id="redPen"/> <brush xml:id="bluePen"/> <traceFormat xml:id="normal"/> <traceFormat xml:id="noForce"/> <context xml:id="context1" brushRef="#redPen" traceFormatRef="#normal"/> <context xml:id="context2" contextRef="#context1" brushRef="#bluePen"/> </definitions> <context contextRef="#context2" traceFormatRef="#noForce"/> <context xml:id="context3"/></ink>
More details on the usage of the<definitions>
element are provided in theArchival Applications section.
InkML provides generic ways of assigning metadata or semanticsto ink via two elements<annotation>
and<annotationXML>
, modeled after the correspondingelements in MathML. However since annotations are typicallyapplication-specific, InkML does not attempt to prescribe thecontents of these elements. Since the contents of<annotation>
or<annotationXML>
elements are applicationdefined, implementers should use them with care and remain awarethat other implementations may ignore them or fail to round-tripunrecognized annotations.
<annotation>
elementOther attributes in a namespace other than that of InkML arealso allowed, such as general metadata properties (e.g. from theDublin Core vocabulary) or application-specific attributes.
The<annotation>
element provides a mechanismfor inserting simple textual descriptions in the ink markup. Thismay be used for multiple purposes. For instance, the text containedin the<annotation>
may include additionalinformation provided by the user generating InkML, and may bedisplayed by an InkML consumer rendering a graphical representationof traces. Or it may be used for the indication of metadata such asthe writer, the writing instrument. Another important potentialapplication is the semantic tagging of traces.
<ink xmlns="http://www.w3.org/2003/InkML" xmlns:dc="http://dublincore.org/documents/2001/10/26/dcmi-namespace/"> <annotation type="description">A Sample of Einstein's Writings</annotation> <annotation type="writer">Albert Einstein</annotation> <annotation type="contentCategory">Text/en</annotation> <annotation type="language" encoding="ISO639">en</annotation> <annotation dc:language="en"/> <trace xml:id="trace1"> ... </trace> <traceGroup xml:id="tg1"> <annotation type="truth">Hello World</annotation> <traceGroup> <annotation type="truth">Hello</annotation> <trace> ... </trace> ... </traceGroup> <traceGroup> <annotation type="truth">World</annotation> <trace> ... </trace> ... </traceGroup> </traceGroup> <traceView traceDataRef="#tg1"/></ink>
For semantic tagging, one of the common types of<annotation>
is "contentCategory", whichdescribes at a basic level the category of content that the tracesrepresent; e.g., "Text/English", "Drawing", "Math", "Music". Suchcategories are useful for general data identification purposes, andmay be essential for selecting data to train handwritingrecognizers in different problem domains.
Although largely application-defined, a number of likely, commoncategories are suggested below.
The language specification may be made using any of the languageidentifiers specified in ISO 639, using 2-letter codes, 3-lettercodes, or country names. Some text may also require a scriptspecification (such as Kanji, Katakana, or Hiragana) in addition tothe language.
For some applications it may be useful to provide additionalsub-categories defining the type of the data. For example, somesuggested sub-categories for Text include:
Suggested possible sub-categories for Drawing are:
<annotationXML>
elementOther attributes in a namespace other than that of InkML arealso allowed, such as general metadata properties (e.g. from theDublin Core vocabulary) or application-specific attributes.
This element allows ink to be annotated with general XMLobjects. For instance a handwritten equation may be described usinga snippet of MathML, or metadata and semantic annotation may beprovided using an XML language. These annotations may be giveneither as the content of an<annotationXML>
element or may be referred to by ahref
attribute, butnot both. If several annotations are desired, several<annotationXML>
elements should be given.
When annotations of a parent node include the content of theannotations of the child nodes, then one should consider using<annotationXML>
annotations on the children withhref
attributes referring to sub-trees of the parentsannotation in order to maintain linear space complexity in theannotations.
<ink xmlns="http://www.w3.org/2003/InkML"> <annotation type="description">A Sample of Einstein's Writings</annotation> <annotationXML type="metadata" encoding="rdf"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" > <rdf:Description about="" dc:language="en" dc:date="2004-04-11" dc:creator="InkML Maker v0.1" dc:publisher="Famous Handwritings Ltd."/> </rdf:RDF> </annotationXML> <trace> ... </trace> ... <trace> ... </trace></ink>
<ink xmlns="http://www.w3.org/2003/InkML"> <annotationXML type="truth" encoding="application/xhtml+xml"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <div xml:id="Ch1"> <h1 xml:id="T1"><span xml:id="W1">Weather </span></h1> <p xml:id="P1"> <span xml:id="W2">The</span> <span xml:id="W3">rain</span> ... more words </p> <p xml:id="P2">...</p> ... more paragraphs </div> ... more chapters </body> </html> </annotationXML> <traceGroup> <annotationXML href="#Ch1"/> <traceGroup> <annotationXML href="#T1"/> <traceGroup> <!-- Weather --> <annotationXML href="#W1"/> <trace>...</trace> </traceGroup> </traceGroup> <traceGroup> <annotationXML href="#P1"/> <traceGroup> <!-- The --> <annotationXML href="#W2"/> <trace>...</trace> </traceGroup> <traceGroup> <!-- rain --> <annotationXML href="#W3"/> <trace>...</trace> </traceGroup> ... more words in paragraph </traceGroup> </traceGroup> <traceGroup> <annotationXML href="#P2"/> ... words in paragraph </traceGroup> ... more paragraphs in chapter.</ink>
If it were not for the sharing of the substructure of theattribute XML data, then each attribute word would be repeatedthree times (as a word, in a paragraph, and in a chapter), eachparagraph would be repeated twice, etc.
Units are used in several parts of ink mark up. For examplechannels may report their values with some dimension, such aslength, requiring units. Other elements may give values, such asresolution, as quantities in particular units.
The following abbreviations must be recognized as unit attributevalues.
Dimension | Unit | Interpretation |
---|---|---|
length | m | meters |
cm | centimeters | |
mm | millimeters | |
in | inches | |
pt | points (1pt = 1/72 in) | |
pc | picas (1pc = 1/22 pt) | |
em | ems, the width of a letter "M" in a notional normal size | |
ex | exs, the height of a letter "x" in a notional normal size | |
time | s | seconds |
ms | milliseconds | |
mass | kg | kilograms |
g | grams | |
mg | milligrams | |
force | N | Newtons |
angle | deg | degrees |
rad | radians | |
all | % | percentage, expressed as a fraction (1.0 = 100%) relative tomax-min |
dev | quanta relative to a device resolution. This can correspond topixels, force levels, clock ticks, etc. |
In addition to the units named above, the following expressionsmust also be recognized:
unitExpr ::= unit | "1" "/" unit | unitExpr "/" unit | unitExpr "*" unitunitPrimitive ::= unit | "(" unitExpr ")"unit ::=one of the units from the table above, with the exception of em, ex, % and dev.
Other units are permitted, but need not be recognized by acompliant application.
The ink markup is expected to be used in many differentscenarios. Ink markup data may be transmitted in substantially realtime while exchanging ink messages, or ink documents may bearchived for later retrieval or processing. InkML has been designedwith both of these uses in mind, and it is natural to use InkML ina particular way in each of these settings.
These settings illustrate two different styles of ink generationand usage. In the later, the markup must facilitate the incrementaltransmission of a stream of ink data, while in the former, themarkup should provide the structure necessary for operations suchas search and interpretation. In order to support both cases, InkMLprovides archival and streaming modes of usage. These are notdistinct and incompatible languages, but rather are two stylizedways of using InkML.
Archival applications typically handle ink data that has beencollected over some span of time and has some structure,organization or interpretation associated to the ink data. Theseapplications may re-organize ink traces so it is preferable thatthe traces be state-free. That is, in archival applications, to theextent that ink traces make use of context information, this isalways done explicitly and never through the "current" context.
In archival usage, contextual elements occur within one or more<definitions>
elements and are assignedidentifiers using the id attribute. References to defined elementsare made using the correspondingbrushRef,traceFormatRef, andcontextRef attributes. This isillustrated in the following example:
<definitions> <brush xml:id="penA"/> <brush xml:id="penB"/> <traceFormat xml:id="fmt1"> <channel name="X" type="integer"/> <channel name="Y" type="integer"/> <channel name="Z" type="integer"/> </traceFormat> <canvas xml:id="canvasA"> <traceFormat> <channel name="X" type="decimal" min="0" max="200" units="mm"/> <channel name="Y" type="decimal" min="0" max="150" units="mm"/> </traceFormat> </canvas> <canvasTransform xml:id="trans1"> <mapping type="affine">1 0 0 0,0 1 0 0</mapping> </canvasTransform> <canvasTransform xml:id="trans2"> <mapping type="affine">2 0 0 0,0 -2 0 0</mapping> </canvasTransform> <context xml:id="context1" canvasRef="#canvasA" canvasTransformRef="#trans1" traceFormatRef="#fmt1" brushRef="#penA"/> <context xml:id="context2" canvasRef="#canvasA" canvasTransformRef="#trans2" traceFormatRef="#fmt1" brushRef="#penB"/></definitions>
This example defines two brushes ("penA" and "penB"), atraceFormat ("fmt1"), and two contexts ("context1" and "context2")which both refer to the same canvas ("canvasA") and traceFormat("fmt1"), but with different canvas transforms and brushes. Notethe use of thebrushRef,traceFormatRef,canvasRef andcanvasTransformRef attributes to referto previously defined<brush>
,<traceFormat>
<canvas>
and<canvasTransform>
elements.
Within the scope of a<definitions>
element,unspecified attributes of a<context>
elementare assumed to have their default values. The<definitions>
block below defines "context1",which is comprised of "canvasA" with the default canvasTransformand traceFormat (the identity mapping and a traceFormat consistingof decimal X-Y coordinate pairs), and "penA".
<definitions> <brush xml:id="penA"/> <context xml:id="context1" canvasRef="#canvasA" brushRef="#penA"/></definitions>
A<context>
element can inherit and overridethe values of a previously defined context by including acontextRef attribute, so the following block defines "context2"which shares the same canvas ("canvasA") and traceFormat (thedefault format) as "context1", but has a different canvasTransformand brush.
<definitions> <brush xml:id="penA"/> <context xml:id="context1" canvasRef="#canvasA" canvasTransformRef="#trans1"/> <context xml:id="context2" contextRef="#context1" canvasTransformRef="#trans2" brushRef="#penA"/></definitions>
Within archival ink markup, traces can either explicitly specifytheir context through the use of contextRef and brushRefattributes, or they can have their context provided by an enclosingtraceGroup. In the following example, traces "t001" and "t003" havethe context defined by "context1", while trace "t002" has a contextconsisting of the default canvas, canvasTransform and traceFormat,and "penA".
<trace xml:id="t001" contextRef="#context1">...</trace><trace xml:id="t002" brushRef="#penA">...</trace><traceGroup contextRef="#context1"> <trace xml:id="t003">...</trace></traceGroup>
Traces within a<traceGroup>
element can alsooverride the context or brush specified by the traceGroup. In thefollowing example, traces "t001" and "t003" have their contextspecified by "context1" while trace "t002" overrides the defaultbrush of "context1" with "penA".
<traceGroup contextRef="#context1"> <trace xml:id="t001">...</trace> <trace xml:id="t002" brushRef="#penA">...</trace> <trace xml:id="t003">...</trace></traceGroup>
A trace or traceGroup can both reference a context and overrideits brush, as in the following example which assigns the contextspecified by "context1" to traces "t001" and "t002", but with"penA" instead of the default brush.
<trace xml:id="t001" contextRef="#context1" brushRef="#penA">...</trace><traceGroup contextRef="#context1" brushRef="#penA"> <trace xml:id="t002">...</trace></traceGroup>
In archival mode, the ink markup processor can straightforwardlydetermine the context for a given trace by examining only the<definitions>
blocks within the markup and theenclosing traceGroup for the trace.
Streaming ink applications present digital ink traces insequential time order. Contextual information is inserted into thestream of ink traces, as needed, to provide interpretation for theink strokes. These changes to the current trace context are givenby<context>
elements. These may directlycontain brush, trace format and other information or which mayrefer to previously seen such elements. This corresponds to anevent-driven model of ink generation, where events which result incontextual changes map directly to elements in the markup.
The current context consists of the set of canvas,canvasTransform, traceFormat and brush which are associated withsubsequent traces in the ink markup. Initially, the current contextcontains the default canvas, an identity canvasTransform, thedefault traceFormat, and a brush with no attributes. Each<brush>
,<traceFormat>
, and<context>
element which appears outside of a<definitions>
element changes the currentcontext accordingly (elements appearing within a<definitions>
block have no effect on thecurrent context, and behave as described above in the archivalsection).
The appearance of a<brush>
element in theink markup sets the current brush attributes, leaving all othercontextual values the same. Likewise, the appearance of a<traceFormat>
element sets the currenttraceFormat, and the appearance of a<context>
element sets the current context.
Outside of a<definitions>
block, any valueswhich are not specified within a<context>
element are taken from the current context. For instance, the<context>
element in the following examplechanges the current brush from "penB" to "penA", leaving thecanvas, canvasTransform, and traceFormat unchanged from trace"t001" to trace "t002". That is, each context element is taken toinherit from the previously established context.
<brush xml:id="penA"/><brush xml:id="penB"/><trace xml:id="t001">...</trace><context brushRef="#penA"/><trace xml:id="t002">...</trace>
In order to change a contextual value back to its default value,its attribute can be specified with the value "#DefaultCanvas" or "#DefaultBrush". In thefollowing:
<context canvasRef="#canvasA" brushRef="#penA"/><trace xml:id="t001">...</trace><context canvasRef="#DefaultCanvas" brushRef="#DefaultBrush"/><trace xml:id="t002">...</trace>
Trace "t001" is on "canvasA" and has the brush specified by"penA", while trace "t002" is on the default canvas and has thedefault brush.
Brushes, traceFormats, and contexts which appear outside of a<definitions>
block and contain anidattribute both set the current context and define contextualelements which can be reused (as shown above for the brushes "penA"and "penB"). This example:
<context xml:id="context1" canvasRef="#canvasA" canvasTransformRef="#trans1" traceFormatRef="#fmt1" brushRef="#penA"/>
defines a context which can be referred to by its identifier"context1". It also sets the current context to the valuesspecified in the<context>
element.
A previously defined context is referenced using thecontextRef attribute of the<context>
element. For example:
<context contextRef="#context1"/>
sets the current context to have the values specified by"context1". A<context>
element can alsooverride values of a previously defined context by including both acontextRef attribute and one or more of thecanvasRef,canvasTransformRef,traceFormatReforbrushRef attributes. The following:
<context contextRef="#context1" brushRef="#penB"/>
sets the current context to the values specified by "context1",except that the current brush is set to "penB" instead of"penA".
A<context>
element which inherits andoverrides values from a previous context can itself be reused, sothe element:
<context xml:id="context2" contextRef="#context1" brushRef="#penB"/>
defines "context2" which has the same context values as"context1" except for the brush.
Finally, a<context>
element with only an idhas the effect of taking a "snapshot" of the current context whichcan then be reused. The element:
<context xml:id="context3"/>
defines "context3", whose values consist of the currentcanvasRef, canvasTransform, traceFormat, and brush at the pointwhere the element occurs (note that since "context3" does notspecify any values, the element has no effect on the currentcontext).
An advantage of the streaming style is that it is easier toexpress overlapping changes to the individual elements of thecontext. However, determining the context for a particular tracecan require more computation from the ink markup processor, sincethe entire file may need to be scanned from the beginning in orderto establish the current context at the point of the<trace>
element.
While it is possible to wait and generate each trace as it iscompleted, this can lead to considerable latency from the startingtime with long strokes. This may be avoided bygenerating traces of partial strokes and using continuationtraces.
Finally, it should be noted that traces can overlap intime. This can occur in collaborative applications withseveral writers or with one user on "multi-touch" devices. Here it is also possible to generate traces for complete strokes onpen up, but applications may use partial strokes of limited timeduration to guarantee that a buffer restricted to a sliding timewindow sees all simultaneous traces.
The following examples of archival and streaming ink markup dataare equivalent, but they highlight the differences between the twostyles:
Archival
<ink xmlns="http://www.w3.org/2003/InkML"> ... <definitions> <brush xml:id="penA"/> <brush xml:id="penB"/> <context xml:id="context1" canvasRef="#canvas1" canvasTransformRef="#trans1" traceFormatRef="#format1"/> <context xml:id="context2" contextRef="#context1" canvasTransformRef="#trans2"/> </definitions> <traceGroup contextRef="#context1"> <trace>...</trace> ... </traceGroup> <traceGroup contextRef="#context2"> <trace>...</trace> ... </traceGroup> <traceGroup contextRef="#context2" brushRef="#penB"> <trace>...</trace> ... </traceGroup> <traceGroup contextRef="#context1" brushRef="#penB"> <trace>...</trace> ... </traceGroup> <traceGroup contextRef="#context1" brushRef="#penA"> <trace>...</trace> ... </traceGroup></ink>
Streaming
<ink xmlns="http://www.w3.org/2003/InkML"> ... <definitions> <brush xml:id="penA"/> <brush xml:id="penB"/> </definitions> <context xml:id="context1" canvasRef="#canvas1" canvasTransformRef="#trans1" traceFormatRef="#format1"/> <trace>...</trace> ... <context xml:id="context2" contextRef="#context1" canvasTransformRef="#trans2"/> <trace>...</trace> ... <context brushRef="#penB"/> <trace>...</trace> ... <context contextRef="#context1"/> <trace>...</trace> ... <context brushRef="#penA"/> <trace>...</trace> ... </ink>
In the archival case, the context for each trace is simplydetermined by the<trace>
element, its enclosingtraceGroup, and contextual elements defined in the<definitions>
block, while in the streamingcase, the context for a trace can depend on the entire sequence ofcontext changes up to the point of the<trace>
element.
However, the streaming case more simply expresses the changes ofcontext involving "penB", "context1", and "penA", whereas thearchival case requires the restatement of the unchanged values inthe successive traceGroups.
The two styles of ink markup are equally expressive, but imposedifferent requirements on the ink markup processor and generator.Tools to translate from streaming to archival style might also beof use to applications which work on stored ink markup.
The contents of this section are normative.
A document is a Conforming InkML Document if it meets both the following conditions:
The InkML specification and these conformance criteria provide no designated size limits on any aspect of InkML documents. There are no maximum values on the number of elements, the amount of character data, or the number of characters in attribute values.
Within this specification, the term URI refers to a Universal Resource Identifier as defined in [RFC3986] and extended in [RFC3987] with the new name IRI. The term URI has been retained in preference to IRI to avoid introducing new names for concepts such as "Base URI" that are defined or referenced across the whole family of XML specifications.
The InkML namespace is intended to be used with other XML namespaces as per the Namespaces in XML Recommendation [XMLNS]. Future work by W3C is expected to address ways to specify conformance for documents involving multiple namespaces.
An InkML processor is a program that can process and/or generate Conforming InkML documents.
In a Conforming InkML Processor, the XML parser MUST be able to parse and process all XML constructs defined by XML 1.1 [XML] and Namespaces in XML [XMLNS]. It is not required that a Conforming InkML Processor uses a validating XML parser.
A Conforming InkML Processor MUST correctly understand and apply the semantics of each markup element or attribute as described by this document.
There is, however, no conformance requirement with respect to performance characteristics of the InkML Processor. For instance, no statement is required regarding the accuracy, speed or other characteristics of output produced by the processor. No statement is made regarding the size of input that a InkML Processor is required to support.
We thank our colleagues at IBM for providing their work in 2002as a starting point for this definition.
We thank all participants in the InkML activity of theMultimodal Interaction Working Group for the many detailedconstructive discussions. Without the participants' desire toobtain the best outcome, regardless of corporate affiliation, thiswork would not have been possible.
We specifically thank the W3C staff who have supported the InkMLactivity: Max Froumentin who served as a staff member of W3C until2006 and served as editor of previous working drafts and KazuyukiAshimura who then took responsibility for the InkML activity at W3Cand has provided continuous energy and support.
Finally, we thank Deborah Dahl, whose stewardship of the W3CMultimodal Interaction Working Group has provided the perfectenvironment for this work to come to fruition.
The following are informative implementation guidelines forreducing InkML file size and environmental interactions.
The lossless gzip compression [RFC1952] will help to reduce the InkMLfile size considerably. It is recommend that applicationshave the facility to compress and decompress InkML files andstreams using the gzip algorithm.
The lossless gzip compression [RFC1952] will help to reduce the InkMLfile size
The elements which define constructs that can bereferenced repeatedly such as<brush>
definitions, and
Applications should take advantage of trace dataprefixes (' | " | *) for defining relative coordinate values. The use of first and second order derivative coordinates caneffectively compress
Applications should make use of the 'currentcontext' to cache the context property values and hence reduce thecontext property markups that are being sent explicitly along withtrace data.
Any of the usual XML protocols (StAX, SOAP, etc)may be used to transmit InkML documents or fragments betweensubprograms or distributed programs.
Client and server applications that wish tostream InkML should have the capability to process the data sent inmultiple fragments of InkML packets. The receipt of suchInkML fragments may progressively render on the client orclients.
This appendix registers a new MIME media type,"application/inkml+xml
".
The"application/inkml+xml
"media type is registered with IANA athttp://www.iana.org/assignments/media-types/application/.
application
inkml+xml
None.
charset
This parameter has identical semantics to thecharset
parameter of theapplication/xml
media type as specified in [RFC3023] or its successor.
By virtue of InkML content being XML, it has the sameconsiderations when sent as "application/inkml+xml
" asdoes XML. See RFC 3023 (or its successor), section 3.2.
InkML elements may include arbitrary URIs.Therefore the security issues of[RFC3986], section 7, should beconsidered.
In addition, because of the extensibility features for InkML, itis possible that "application/inkml+xml
" may describecontent that has security implications beyond those described here.However, if the processor follows only the normative semantics ofthis specification, this content will be ignored. Only in the casewhere the processor recognizes and processes the additionalcontent, or where further processing of that content is dispatchedto other processors, would security issues potentially arise. Andin that case, they would fall outside the domain of thisregistration document.
This specification describes processing semantics that dictatebehavior that must be followed when dealing with, among otherthings, unrecognized elements.
Because InkML is extensible, conformant"application/inkml+xml
" processors MAY expect thatcontent received is well-formed XML, but processors SHOULD NOTassume that the content is valid InkML or expect to recognize all ofthe elements and attributes in the document.
This media type registration is extracted from Appendix D oftheInk Markup Language(InkML) specification.
There is no single initial octet sequence that is always presentin InkML documents.
InkML documents are most often identified with the extensions".ink
" or ".inkml
".
TEXT
Kazuyuki Ashimura, <ashimura@w3.org>.
COMMON
The InkML specification is a work product of the World Wide WebConsortium's Multimodal Interaction Working Group. The W3C haschange control over these specifications.
For documents labeled as "application/inkml+xml
",the fragment identifier notation is exactly that for"application/xml
", as specified in RFC 3023.
This section defines the formal syntax for InkML documents interms of a normative XML Schema.
The latest version of the XML Schema for InkML is available at http://www.w3.org/TR/InkML/inkml.xsd.
For stability it is RECOMMENDED that you use the dated URI available athttp://www.w3.org/TR/2011/REC-InkML-20110920/inkml.xsd.