Chapter 19. Vector Markup Language

The way you present XML in browsers should not be limited to simple text—in fact, there are various initiatives to create graphics-based XML applications. We created graphical browsers in Chapter 11, "Java and the XML DOM," and Chapter 12, "Java and SAX," to use XML to display circles. I also discussed the W3C language, Scalable Vector Graphics (SVG), in Chapter 1, "Essential XML." SVG has been around for a long time but has not been very widely implemented. Today, the most widespread graphics-based XML application is the Vector Markup Language (VML) from Microsoft.

Here's how Microsoft describes VML: "VML is an application of Extensible Markup Language (XML) 1.0 which defines a format for the encoding of vector information together with additional markup to describe how that information may be displayed and edited."

VML supports the markup of vector graphic information in the same way that HTML supports the markup of textual information. Besides its own XML elements, VML also supports CSS, so you can style and position shapes as you like. It's supported in Microsoft Office 2000—Microsoft Word, PowerPoint, and Excel. When you create graphics in those programs, the graphics are stored in VML. Internet Explorer also supports VML. You can use the tools that come with Microsoft Office to draw VML figures, or you can create VML yourself. We'll do it ourselves in this chapter.

There are two primary online resources for VML: the VML reference at Microsoft, and the note that Microsoft wrote and sent to the W3C, which the W3C has posted (not much has come of that note; no one besides Microsoft seems very inclined to implement VML). Here are these resources (bear in mind that URIs on Microsoft's sites change very frequently):

VML was added to Internet Explorer before that browser added its built-in XML support, so the way you implement VML does not involve Internet Explorer XML islands or any such mechanism. Instead, you use a namespace for VML and then use the VML engine in Internet Explorer, which is actually implemented as an Internet Explorer behavior (an external code module). We saw this example in Chapter 1, and I'll take a closer look at it in this chapter:

<HTML xmlns:v="urn:schemas-microsoft-com:vml">

    <HEAD>
        <TITLE>
            Using Vector Markup Language
        </TITLE>

        <STYLE>
        v:* {behavior: url(#default#VML);}
        </STYLE>
    </HEAD>

    <BODY>
        <CENTER>
            <H1>
                Using Vector Markup Language
            </H1>
        </CENTER>
        <P>
        <v:oval STYLE='width:100pt; height:75pt'
            fillcolor="yellow" />
        <P>
        <v:rect STYLE='width:100pt; height:75pt' fillcolor="blue"
            strokecolor="red" STROKEWEIGHT="2pt"/>
        <P>
        <v:polyline
            POINTS="20pt,55pt,100pt,-10pt,180pt,65pt,260pt,25pt"
            strokecolor="red" STROKEWEIGHT="2pt"/>
    </BODY>
</HTML>

Internet Explorer Behaviors

You can find out more about Internet Explorer behaviors, which represent one of Microsoft's techniques for separating markup from document content, at http://msdn.microsoft.com/workshop/c-frame.htm#/workshop/author/default.asp


This example just drew a few VML shapes, and you can see the results of this page in Figure 19.1.

Figure 19.1. A VML page sample page.


Now that we're discussing VML in depth, the syntax of this document bears a little examination.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.204