C H A P T E R  7

PML Utilities

This chapter describes the Sun Java System RFID Software PML Utilities. The following sections are included:


Introduction

The purpose of the core physical markup-language (PML Core) is to provide a standardized format for the exchange of data captured by the sensors in an RFID infrastructure, for example, RFID readers. This data is exchanged between the Event Manager and other applications. PML Core provides a set of XML schemas that define the interchange format for the transmission of the data values captured.

The PML Utilities Java library provides helper classes to parse and manipulate PML Core messages. This library is intended for use in any application that interfaces with the Event Manager. These utilities are located in the file sun-rfid-common.jar. TABLE 7-1 lists the default locations of this file for the supported platforms.


TABLE 7-1 Location of PML Utilities JAR File

Platform

Location

Solaris OS

/opt/SUNWrfid/lib

Linux

/opt/sun/rfidem/lib

Microsoft Windows

C:\Program Files\Sun\RFID Software\rfidem\lib


Supported version is PML_Core v1.0 (AutoID Center recommendation 15 September, 2003).


Capturing Tag Observations Using PML Core

This section describes a sample core message for capturing tag observations.


CODE EXAMPLE 7-1 Sample Core Message for Capturing Tag Observations

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!-- The root element of PML Core -->
<Sensor xmlns="urn:autoid:specification:interchange:PMLCore:xml:schema:1">

<!-- The EPC of the reader specified in the reader adapter properties -->
<ns1:ID xmlns:ns1="urn:autoid:specification:universal:Identifier:xml:schema:1">urn:epc:id:gid:1.1.100

</ns1:ID>

<!-- The root element for an observation -->
<Observation>
<ns2:ID xmlns:ns2= "urn:autoid:specification:universal:Identifier:xml:schema:1">2

</ns2:ID>

<!-- The time when the observation was recorded by the reader adapter -->

<DateTime>2004-05-21T18:28:16.633-07:00</DateTime>

<!-- If the PML is generated from a Delta Event the value of Command is either TagsIn or TagsOut -->

<Command>TagsOut</Command>

<!-- A tag observation -->
<Tag>

<!-- The EPC of the observed tag in identity URI format -->
<ns3:ID xmlns:ns3="urn:autoid:specification:universal:Identifier:xml:schema:1">urn:epc:id:gid:1.1.110</ns3:ID>
</Tag>

<Tag>

<ns4:ID xmlns:ns4="urn:autoid:specification:universal:Identifier:xml:schema:1">urn:epc:id:gid:1.1.105</ns4:ID>

</Tag>

<Tag>

<ns5:ID xmlns:ns5="urn:autoid:specification:universal:Identifier:xml:schema:1">urn:epc:id:gid:1.1.104</ns5:ID>

</Tag>

</Observation>

</Sensor>

 



PML Utilities Packages

This section describes the following PML utilities packages:

PML Core Package

The com.sun.autoid.pmlcore.pml package is generated from the PML Core XML Schema document using the JAXB compiler. The generated classes can be used to traverse an existing Java object graph or to create a new one. See CODE EXAMPLE 7-2.


CODE EXAMPLE 7-2 Sample XML to Create a New PML Message
/**
      * Create a sample PML Core XML message.
      */
    public SensorType createPMLCore() {
        SensorType sensor = null;
        try {
            PmlParser pmlParser = new PmlParser();
            ObjectFactory objFactory = pmlParser.getPMLObjectFactory();
            sensor = objFactory.createSensor();
                                                                                
            /* Create the reader EPC */
            IdentifierType idType = objFactory.createIdentifierType();
            idType.setValue("urn:epc:id:gid:1.700.1");
            sensor.setID(idType);
                                                                                
            /* Create the Observation object */
            List obsList = sensor.getObservation();
            ObservationType obs = objFactory.createObservationType();
            obsList.add(obs);
                                                                                
            /* Timestamp of the observation */
            obs.setDateTime(Calendar.getInstance());
            /* The command element is optional.
                if specified it is either :
                TagsIn or TagsOut */
                obs.setCommand("TagsIn");
            /* Observation ID is currently ignored */
            idType = objFactory.createIdentifierType();
            idType.setValue("1");
            obs.setID(idType);
                                                                                
            /* create Tags and assign them to the Observation object */
            TagType tag = objFactory.createTagType();
            idType = objFactory.createIdentifierType();
            idType.setValue("urn:epc:id:gid:10.10.1");
            tag.setID(idType);
            obs.getTag().add(tag);
                                                                                
            tag = objFactory.createTagType();
            idType = objFactory.createIdentifierType();
            idType.setValue("urn:epc:id:gid:10.10.2");
            tag.setID(idType);
            obs.getTag().add(tag);
            /* debug */
            System.out.println("Sensor BEGIN");
            SensorUtil.dump((com.sun.autoid.pmlcore.pml.Sensor)sensor);
            System.out.println("Sensor END");
                                                                                
        } catch (JAXBException jbe) {
            jbe.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sensor;
    }
 

PML Parser Package


TABLE 7-2 Database Tables

Java Class

Descriptor

PmlParser

A Parser that reads Product Markup Language and creates a Java Object Graph.

SensorUtil

A class to dump the Sensor JAXB Tree.


Unmarshalling an XML File Using the PmlParser


CODE EXAMPLE 7-3 Sample XML to Unmarshall a PML Core XML File
/* Unmarshall a PML Core XML file */
    public Sensor pmlCoreFromFile() {
        Sensor sensor = null;
        try {
		/* Create an instance of PmlParser */
            PmlParser pmlParser = new PmlParser();
            /* Call the unmarshall method */
            sensor = pmlParser.unmarshalPML(new File("./pml_sample.xml"));
            /* debug message */
            System.out.println("Sensor BEGIN");
            SensorUtil.dump(sensor);
            System.out.println("Sensor END");
        } catch (JAXBException jbe) {
            jbe.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sensor;
     }


Class Path Requirements

The JAR files (JAXB 1.0.4 and its dependant jar files from Java WSDP 1.5) that are used to compile and run an application that uses the PML utilities are shown in TABLE 7-3.


TABLE 7-3 PML Utilities Jar Files

$JWSDP_HOME/jaxb/lib/jaxb-api.jar

$JWSDP_HOME/jaxb/lib/jaxb-impl.jar

$JWSDP_HOME/jaxb/lib/jaxb-libs.jar

$JWSDP_HOME/jwsdp-shared/lib/namespace.jar

$JWSDP_HOME/jwsdp-shared/lib/relaxngDatatype.jar

$JWSDP_HOME/jwsdp-shared/lib/jax-qname.jar

$JWSDP_HOME/jwsdp-shared/lib/xsdlib.jar

$JWSDP_HOME/jaxp/lib/jaxp-api.jar

$JWSDP_HOME/jaxp/lib/endorsed/dom.jar

$JWSDP_HOME/jaxp/lib/endorsed/sax.jar

$JWSDP_HOME/jaxp/lib/endorsed/xercesImpl.jar



UML Class Diagram For PML Package


UML class diagram for RFID PML package.