public void testWrite() throws Exception {
    Car car = new Car();
    car.numberOfDoors = 2;
    car.milesPerGallon = 30;
    car.model = "Grand Am";
    car.manufacturer = "Pontiac";
    car.topSpeed = 220;

    Document carDocument = marshaller.objectToXML(car);
    Element root =
        (Element) carDocument.getElementsByTagNameNS("mynamespaceuri", "vehicle").item(0);
    Attr elem = root.getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "type");
    String carType = elem.getNodeValue();
    assertTrue(
        "The type field was written incorrectly for the subclass",
        carType.equals("prefix:car-type"));

    Vehicle vehicle = new Vehicle();
    vehicle.model = "Blah Blah";
    vehicle.manufacturer = "Some Place";
    vehicle.topSpeed = 10000;

    Document vehicleDocument = marshaller.objectToXML(vehicle);
    root = (Element) vehicleDocument.getElementsByTagNameNS("mynamespaceuri", "vehicle").item(0);
    elem = root.getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "type");
    String vehicleType = elem.getNodeValue();
    assertTrue(
        "The type field was written incorrectly for the superclass",
        vehicleType.equals("prefix:vehicle-type"));
  }