Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XML and Windows CE 3.0

Windows CE 3.0

Microsoft Corporation

November 2000

Summary: Windows CE 3.0 operating system extends the range of options available to developers by providing a subset of Extensible Markup Language (XML) functionality. This document describes the features of XML that have been incorporated into Windows CE and the differences between using XML on a Windows CE–based platform and on a Windows-based desktop computer. (9 printed pages)

Content

Introduction
Extensible Markup Language
   Web Services and XML
XML for Windows CE
   Validating Data
   Document Management
   Formatting Complex Data for Presentation
   XMLHTTP
   Instantiation of COM Objects Through XSL

Introduction

The Microsoft® Windows® CE 3.0 operating system extends the range of options available to developers by providing a subset of Extensible Markup Language (XML) functionality. This document describes the features of XML that have been incorporated into Windows CE and the differences between using XML on a Windows CE–based platform and on a Windows-based desktop computer. For general information about XML, see the documentation available in the MSDN Online Library. (Note that throughout this article, MSXML refers to the XML parser available from Microsoft, and XML refers to the markup language.)

Extensible Markup Language

XML is a meta-markup language that provides a format for describing structured data and allows developers to easily describe and deliver rich, structured data from any application in a standard, consistent way. XML facilitates more precise declarations of content and provides more meaningful search results across multiple platforms. In addition, XML is enabling a new generation of Web-based applications for viewing and manipulating data.

The power and beauty of XML comes from its maintaining the separation of the user interface from the structured data. While Hypertext Markup Language (HTML) tags can display a word in bold face or italics, XML provides a framework for tagging structured data. An XML tag can indicate that the data associated with the tag is a retail price, a sales tax, a book title, an amount of precipitation, or any other desired data. As XML tags are adopted by organizations for their intranets, and by others across the Internet, the ability to search for and manipulate data, regardless of the applications within which the data resides, will increase. Once an application locates XML data, the application can deliver the data over the network and present the data in a Web browser (such as Microsoft® Internet Explorer) in any number of ways, or the application can hand off the data to other applications for further processing and viewing.

XML, which provides a data standard that can encode the content, semantics, and schemata for a wide variety of cases ranging from simple to complex, can be used to mark up the following:

  • An ordinary document
  • A structured record, such as an appointment record or purchase order
  • An object with data and methods, such as the persistent form of a Java object or ActiveX® control
  • A data record, such as the result set of a query
  • Metacontent about a Web site, such as Channel Definition Format (CDF)
  • A graphical presentation, such as an application's user interface
  • Standard schema entities and types
  • All links between information and people on the Web

Once the data is on the client desktop, it can be manipulated, edited, and presented in multiple views without return trips to the server. Servers can now become more scalable, due to lower computational and bandwidth loads. Also, because data is exchanged in the XML format, it can be easily merged from different sources.

Web Services and XML

Unlike current component technologies, Web services do not use object-model-specific protocols such as Distributed Component Object Model (DCOM), Remote Method Invocation (RMI), or Internet Inter-ORB Protocol (IIOP) that require specific, homogeneous infrastructures on both the client and service machines. While implementations tightly coupled to specific component technologies are perfectly acceptable in a controlled environment, they become impractical on the Web. As the set of participants in an integrated business process changes, and as technology changes over time, it becomes very difficult to guarantee a single, unified infrastructure among all participants. Web services take a different approach: They communicate using ubiquitous Web protocols and data formats such as Hypertext Transfer Protocol (HTTP) and XML. Any system supporting these Web standards will be able to support Web services.

Furthermore, a Web service contract describes the services provided in terms of the messages the Web service accepts and generates rather than how the service is implemented. By focusing solely on messages, the Web services model is completely independent of the language, platform, and object model used. A Web service can be implemented using the full feature set of any programming language, object model, and platform.

XML is the obvious choice for defining a standard yet extensible language to represent commands and typed data. While rules for representing commands and typed data using other techniques (such as encoding as a query string) could be defined, XML is specifically designed as a standard metalanguage for describing data.

XML is also the enabling technology for Web service contracts. The Service Contract Language (SCL) is an XML grammar for documenting Web service contracts. Because SCL is XML-based, contracts are easy for both developers and developer tools to create and interpret.

For more information about Microsoft Web Services, see The Programmable Web: Web Services Provides Building Blocks for the Microsoft .NET Framework.

XML for Windows CE

Microsoft Windows CE 3.0 supports a subset of MSXML 2.0 functionality. Specifically, Windows CE does not support the following features:

  • Simple data types on attributes
  • Addition of an "id" data type for elements
  • Assignment of data types through element names
  • Data islands
  • Data binding
  • Mime Type viewer
  • Backward compatibility with the Microsoft XML Document Object Model (DOM) supported by Microsoft Internet Explorer 4.0

Also, Windows CE provides only limited XML security.

Some of the MSXML 2.0 features that are supported in Windows CE are:

  • XML validation through schema, namespace, and data type support.
  • The ability to build and manage complex documents and data through Document Object Model (DOM) support.
  • Web browser formatting through Extensible Stylesheet Language (XSL) support.
  • Automated document requests and parsing functions through the use of XMLHTTP features.

Windows CE also supports the ability to instantiate Component Object Model (COM) objects within blocks of an XSL script, which is a feature of MSXML 2.5.

Validating Data

MSXML for Windows CE supports a technical preview release of XML schemata. The XML schema support is a subset of the Worldwide Web Consortium (W3C) XML data submission and is functionally very close to the W3C Document Content Description (DCD) submission.

Consider the following XML file:

<CONTACTS>
    <CONTACT>
        <NAME>Stephanie Smith</NAME>
        <BIRTHDATE>1971-07-01</BIRTHDATE>
        <EMAIL>ssmith@abcdef.com</EMAIL>
        <PHONE>(425) 111-1111</PHONE>
    </CONTACT>
    <CONTACT>
        <NAME> Bill Williams</NAME>
        <BIRTHDATE>1968-09-17</BIRTHDATE>
        <EMAIL>billw@abcdef.com</EMAIL>
        <PHONE>(425) 111-1111</PHONE>
    </CONTACT>
    <CONTACT>
        <NAME>Christopher Jones</NAME>
        <BIRTHDATE>1999-09-08</BIRTHDATE>
        <EMAIL>cjones@abcdef.com</EMAIL>
        <PHONE>(425) 111-1111</PHONE>
    </CONTACT>
</CONTACTS>

With the new XML schema support in MSXML for Windows CE, the above data can be validated against a schema by declaring the following namespace on the root element:

<CONTACTS xmlns="x-schema:contactSchema.xml">

This sets the schema contactSchema.xml as the default namespace for the document. Other namespaces can be declared throughout the document if desired, but, where no namespace is specified, the default will apply.

The complete schema for the above XML document is as follows:

<Schema xmlns="urn:schemas-microsoft-com:xml-data"
    xmlns:dt="urn:schemas-microsoft-com:datatypes">
<ElementType name="NAME" content="textOnly"/>
<ElementType name="BIRTHDATE"
             content="textOnly"
             dt:type="date"/>
<ElementType name="EMAIL" content="textOnly"/>
<ElementType name="PHONE" content="textOnly"/>
<ElementType name="CONTACT" content="eltOnly">
   <element type="NAME"/>
   <element type="BIRTHDATE"/>
   <element type="EMAIL"/>
   <element type="PHONE"/>
 </ElementType>
 <ElementType name="CONTACTS"
              content="eltOnly"
              order="many">
   <element type="CONTACT"/>
 </ElementType>
</Schema>

The attribute:

xmlns='urn:schemas-microsoft-com:xml-data'

sets the default namespace for the XML document as the schema namespace. This means that the schema must conform to the syntax for XML schemata. Similarly, the attribute:

xmlns:dt='urn:schemas-microsoft-com:datatypes'
 

declares the data type namespace. This means that data types can now be declared throughout the schema. (Note that the dt prefix on the type attribute is used to type the BIRTHDATE value.)

Document Management

The DOM is a platform-neutral and language-neutral interface that permits scripts to access and update the content, structure, and style of a document. The DOM includes a model for how a standard set of objects representing HTML and XML documents are combined and an interface for accessing and manipulating them. The Microsoft XML Parser on Windows CE has full DOM support in compliance with the W3C DOM recommendation. In addition, it also has the Microsoft extensions that allow access to typed data and namespace information, creation of nodes by node type, and so on. The following is a script that loads an XML document containing the contact information and uses XSL pattern matching to display the phone number of the contact with the name of "Bill Williams":

function showPhone()
{
    var root = Contacts.documentElement;
    var selectedElems =  root.selectNodes("CONTACT[NAME='Bill Williams']");
    var billElem = selectedElems.item(0);
    var phone = billElem.childNodes.item(3).nodeTypedValue;
    alert("Bill Williams phone number is " + phone);
}

The selectNodes method uses XSL pattern-matching to retrieve a node list. In this case, the script looks for all CONTACT elements that have a NAME element with the value of "Bill Williams." Because there is only one element that matches this pattern, selectNodes returns a node list of length one.

Formatting Complex Data for Presentation

MSXML on Windows CE also provides support for XSL, which allows for more complex display of XML data. For instance, the previous contact information can be displayed in a simple table format. The first task would be to create an XSL style sheet:

<xsl:stylesheet xmlns:xsl="uri:xsl">
  <xsl:template match="/">
    <H3>Contacts</H3>
    <TABLE BORDER="1" CELLPADDING="1" CELLSPACING="0">
      <TR>
        <TD BGCOLOR="#C0C0C0"><B>Name</B></TD>
        <TD BGCOLOR="#C0C0C0"><B>Phone</B></TD>
        <TD BGCOLOR="#C0C0C0"><B>Email</B></TD>
      </TR>
      <xsl:for-each select="CONTACTS/CONTACT" order-by="EMAIL">
        <TR>
          <TD><I><xsl:value-of select="NAME"/></I></TD>
          <TD><xsl:value-of select="PHONE"/></TD>
          <TD><xsl:value-of select="EMAIL"/></TD>
        </TR>
      </xsl:for-each>
    </TABLE>
  </xsl:template>
</xsl:stylesheet>

This particular style sheet creates a table and uses the values of selected XML elements to fill the table with information. The style sheet also sorts the information by e-mail name (using the order-by attribute on the xsl:for-each element). Note that the order in which the contact information is displayed differs from the original XML document.

This style sheet can be applied to the XML document through the XML Object Model, which is a set of application programming interfaces (APIs) that allow interaction with the elements of the XML structured tree. The transformNode method on IXMLDOMNode passes in an XSL tree and uses that tree to transform an XML node into an output string. In the following case, that string will be an HTML string that gets inserted into the current document:

function showContacts()
{
    document.write(Contacts.transformNode(ContactsSS.documentElement);
}

The above script displays the following in the browser:

XMLHTTP

Using the XMLHTTP object, the XML tree itself can be posted as an object. In the following script, an XMLHTTP object is created and posts an XML tree named "template" to the server location:

var httpOb = new ActiveXObject("Microsoft.XMLHTTP");
httpOb.Open("POST","http://myServer/postContact.asp", false);
var contact = template.XMLDocument.documentElement;
contact.childNodes.item(0).text = contactName.value;
contact.childNodes.item(1).text = contactPhone.value;
contact.childNodes.item(2).text = contactEmail.value;
httpOb.send(template.XMLDocument);

The XMLHTTP object and its properties are outlined in the IXMLHttpRequest Interface documentation in the MSDN Online Library.

Instantiation of COM Objects Through XSL

Windows CE supports instantiation of COM objects, such as ActiveX controls, through the XSL script interface. The following script demonstrates instantiation of a fictitious COM object, “MyCorp”:

<xsl:script>function TestCOMObject() 
{ 
    var Obj1 = new ActiveXObject("MyCorp.MyComponent"); 
    var y = Obj1.Process(); // Create a new COM object and use it to handle
  // additional processing.
    return y; 
}
</xsl:script> 

Show:
© 2014 Microsoft