adrgen5 - documentation generator
authordevjani.ray@oracle.com <devjani.ray@oracle.com>
Fri, 06 May 2011 14:55:38 -0400
changeset 699 34ec90cc612c
parent 698 3c730b38d1b0
child 700 fe2885279e58
adrgen5 - documentation generator
usr/src/java/adr/org/opensolaris/os/adr/ADRError.java
usr/src/java/adr/org/opensolaris/os/adr/API.java
usr/src/java/adr/org/opensolaris/os/adr/Argument.java
usr/src/java/adr/org/opensolaris/os/adr/Doc.java
usr/src/java/adr/org/opensolaris/os/adr/Event.java
usr/src/java/adr/org/opensolaris/os/adr/Feature.java
usr/src/java/adr/org/opensolaris/os/adr/Field.java
usr/src/java/adr/org/opensolaris/os/adr/HasError.java
usr/src/java/adr/org/opensolaris/os/adr/Interface.java
usr/src/java/adr/org/opensolaris/os/adr/Method.java
usr/src/java/adr/org/opensolaris/os/adr/MethodDiff.java
usr/src/java/adr/org/opensolaris/os/adr/Property.java
usr/src/java/adr/org/opensolaris/os/adr/PropertyDiff.java
usr/src/java/adr/org/opensolaris/os/adr/PropertyError.java
usr/src/java/adr/org/opensolaris/os/adr/Result.java
usr/src/java/adr/org/opensolaris/os/adr/SimpleHasType.java
usr/src/java/adr/org/opensolaris/os/adr/Type.java
usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRGen.java
usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRdocbook.xsl
usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRrmdoc.xsl
usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRtext.xsl
usr/src/java/adr/org/opensolaris/os/adr/adrgen/CGenerator.java
usr/src/java/adr/org/opensolaris/os/adr/adrgen/DocGenerator.java
usr/src/java/adr/org/opensolaris/os/adr/adrgen/JGenerator.java
usr/src/java/build-common.xml
usr/src/java/rad/org/opensolaris/os/rad/ADRXDR.java
usr/src/java/rad/org/opensolaris/os/rad/Client.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/ADRError.java	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ */
+
+package org.opensolaris.os.adr;
+
+/**
+ * An error returned by an adr method or property getter/setter.
+ * The error {@code Type} must be a subclass of {@code Type.ComplexType},
+ * with two exceptions.
+ * If it is {@code null}, the operation can't fail.
+ * If it is {@code StdType.VOID}, the operation may fail but errors
+ * don't include structured data.
+ */
+public class ADRError extends SimpleHasType {
+
+    private Doc doc_;
+
+    public ADRError(Type type, Doc doc) {
+	super(type, false);
+	doc_ = doc;
+    }
+
+    public ADRError(Type type) {
+	this(type, null);
+    }
+
+    public Doc getDoc() {
+	return doc_;
+    }
+}
--- a/usr/src/java/adr/org/opensolaris/os/adr/API.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/API.java	Fri May 06 14:55:38 2011 -0400
@@ -36,16 +36,18 @@
     private Map<String, Property> props_, allProps_;
     private Map<String, Method> methods_, allMethods_;
     private Map<String, Event> events_, allEvents_;
+    private Doc doc_;
     private List<API> parents_;
     private Interface interface_;
 
     public API(String name, Map<Stability, APIVersion> vers,
 	Map<String, Property> props, Map<String, Method> methods,
-	Map<String, Event> events, List<API> parents) {
+	Map<String, Event> events, List<API> parents, Doc doc) {
 
 	name_ = name;
 	vers_ = vers;
 	parents_ = parents;
+	doc_ = doc;
 
 	props_ = props;
 	allProps_ = new HashMap<String, Property>(props_);
@@ -71,6 +73,12 @@
 	}
     }
 
+    public API(String name, Map<Stability, APIVersion> vers,
+	Map<String, Property> props, Map<String, Method> methods,
+	Map<String, Event> events, List<API> parents) {
+	this(name, vers, props, methods, events, parents, null);
+    }
+
     public String getName() {
 	return name_;
     }
@@ -123,6 +131,10 @@
 	return allEvents_.get(name);
     }
 
+    public Doc getDoc() {
+	return doc_;
+    }
+
     /*
      * Definition defintions
      */
--- a/usr/src/java/adr/org/opensolaris/os/adr/Argument.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Argument.java	Fri May 06 14:55:38 2011 -0400
@@ -20,14 +20,17 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 package org.opensolaris.os.adr;
 
 public class Argument extends Feature {
+    public Argument(String name, Type t, boolean optional, Doc doc) {
+	super(name, t, optional, doc);
+    }
+
     public Argument(String name, Type t, boolean optional) {
-	super(name, t, optional);
+	this(name, t, optional, null);
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Doc.java	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,55 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ */
+
+package org.opensolaris.os.adr;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class Doc {
+
+    private Element summary_;
+    private Element detail_;
+    private String lang_;
+
+    public Doc(Element summary, Element detail, String lang) {
+	detail_ = detail;
+	summary_ = summary;
+	lang_ = lang;
+    }
+
+    public Doc(Element summary, Element detail) {
+	this(summary, detail, "en");
+    }
+
+    public Element getSummary() {
+	return summary_;
+    }
+
+    public Element getDetail() {
+	return detail_;
+    }
+}
--- a/usr/src/java/adr/org/opensolaris/os/adr/Event.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Event.java	Fri May 06 14:55:38 2011 -0400
@@ -20,13 +20,17 @@
  */
 
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 package org.opensolaris.os.adr;
 
 public class Event extends Feature {
+    public Event(String name, Stability stability, Type t, Doc doc) {
+	super(name, stability, t, false, doc);
+    }
+
     public Event(String name, Stability stability, Type t) {
-	super(name, stability, t, false);
+	this(name, stability, t, null);
     }
 }
--- a/usr/src/java/adr/org/opensolaris/os/adr/Feature.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Feature.java	Fri May 06 14:55:38 2011 -0400
@@ -25,25 +25,31 @@
 
 package org.opensolaris.os.adr;
 
-public abstract class Feature implements HasType {
+public abstract class Feature extends SimpleHasType {
 
     private API api_ = null;
     protected String name_;
     protected Stability stability_;
-    protected Type type_;
-    protected boolean optional_;
+    protected Doc doc_;
+
+    public Feature(String name, Stability s, Type t, boolean optional,
+	Doc doc) {
+	super(t, optional);
+	name_ = name;
+	stability_ = s;
+	doc_ = doc;
+    }
+
+    public Feature(String name, Type t, boolean optional, Doc doc) {
+	this(name, Stability.UNDEFINED, t, optional, doc);
+    }
 
     public Feature(String name, Stability s, Type t, boolean optional) {
-	name_ = name;
-	stability_ = s;
-	type_ = t;
-	optional_ = optional;
-	if (t != null && t.getSource() == Type.Source.FORWARD)
-	    ((Type.ForwardType)t).addReference(this);
+	this(name, s, t, optional, null);
     }
 
     public Feature(String name, Type t, boolean optional) {
-	this(name, Stability.UNDEFINED, t, optional);
+	this(name, Stability.UNDEFINED, t, optional, null);
     }
 
     public API getAPI() {
@@ -64,17 +70,7 @@
 	return stability_;
     }
 
-    @Override
-    public Type getType() {
-	return type_;
-    }
-
-    @Override
-    public void setType(Type type) {
-	type_ = type;
-    }
-
-    public boolean isOptional() {
-	return optional_;
+    public Doc getDoc() {
+	return doc_;
     }
 }
--- a/usr/src/java/adr/org/opensolaris/os/adr/Field.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Field.java	Fri May 06 14:55:38 2011 -0400
@@ -20,8 +20,7 @@
  */
 
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 package org.opensolaris.os.adr;
@@ -32,33 +31,26 @@
  * will likely add properties to a Feature that shouldn't be added to
  * Fields.
  */
-public class Field implements HasType {
+public class Field extends SimpleHasType {
 
     private String name_;
-    private Type type_;
-    private boolean optional_;
+    private Doc doc_;
+
+    public Field(String name, Type type, boolean optional, Doc doc) {
+	super(type, optional);
+	name_ = name;
+	doc_ = doc;
+    }
 
     public Field(String name, Type type, boolean optional) {
-	name_ = name;
-	type_ = type;
-	optional_ = optional;
-	if (type.getSource() == Type.Source.FORWARD)
-	    ((Type.ForwardType)type).addReference(this);
+	this(name, type, optional, null);
     }
 
     public String getName() {
 	return name_;
     }
 
-    public void setType(Type type) {
-	type_ = type;
-    }
-
-    public Type getType() {
-	return type_;
-    }
-
-    public boolean isOptional() {
-	return optional_;
+    public Doc getDoc() {
+	return doc_;
     }
 }
--- a/usr/src/java/adr/org/opensolaris/os/adr/HasError.java	Thu May 05 13:16:34 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-package org.opensolaris.os.adr;
-
-public interface HasError {
-    /**
-     * Obtains the type of error returned by this operation.  Must be a
-     * subclass of {@code Type.ComplexType}, with two exceptions.
-     * If this returns {@code null}, the operation can't fail.
-     * If this returns {@code StdType.VOID}, the operation may fail but
-     * errors don't include structured data.
-     *
-     * @return the error type
-     */
-    Type getError();
-}
--- a/usr/src/java/adr/org/opensolaris/os/adr/Interface.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Interface.java	Fri May 06 14:55:38 2011 -0400
@@ -36,6 +36,7 @@
  */
 public class Interface {
     private String name_;
+    private Doc doc_;
     private Map<String, Type> allTypes_ = new HashMap<String, Type>();
     private Map<String, Type.ArrayType> arrayTypes_ =
 	new HashMap<String, Type.ArrayType>();
@@ -128,6 +129,24 @@
 	return (at);
     }
 
+    /**
+     * Adds documentation to the interface element.
+     *
+     * @param doc documentation content
+     */
+    public void setDoc(Doc doc) {
+	doc_ = doc;
+    }
+
+    /**
+     * Obtains the documentation associated with this interface
+     * element.
+     *
+     * @return documentation content
+     */
+    public Doc getDoc() {
+	return doc_;
+    }
 
     /**
      * Obtains a specific structured type by name.
--- a/usr/src/java/adr/org/opensolaris/os/adr/Method.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Method.java	Fri May 06 14:55:38 2011 -0400
@@ -20,32 +20,49 @@
  */
 
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 package org.opensolaris.os.adr;
 
 import java.util.List;
 
-public class Method extends Feature implements HasError {
+public class Method extends Feature {
 
+    private Result result_;
     private List<Argument> args_;
-    private Type error_;
+    private ADRError error_;
 
-    public Method(String name, Stability stability, Type t, boolean optional,
-	List<Argument> args, Type error) {
+    public Method(String name, Stability stability, Result result,
+	List<Argument> args, ADRError error, Doc doc) {
 
-	super(name, stability, t, optional);
+	super(name, stability, result.getType(), result.isOptional(), doc);
+	result_ = result;
 	args_ = args;
 	error_ = error;
     }
 
+    public Method(String name, Stability stability, Result result,
+	List<Argument> args, ADRError error) {
+	this(name, stability, result, args, error, null);
+    }
+
     public List<Argument> getArguments() {
 	return args_;
     }
 
-    @Override
-    public Type getError() {
+    public Result getResult() {
+	return result_;
+    }
+
+    /*
+     * If the method operation cannot fail, the error can be null.
+     */
+    public ADRError getError() {
 	return error_;
     }
+
+    public Type getErrorType() {
+	return error_ != null ? error_.getType() : null;
+    }
 }
--- a/usr/src/java/adr/org/opensolaris/os/adr/MethodDiff.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/MethodDiff.java	Fri May 06 14:55:38 2011 -0400
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 package org.opensolaris.os.adr;
@@ -44,10 +44,9 @@
 	    Method mOld = methodsOld.get(mname);
 	    Method mNew = methodsNew.get(mname);
 	    assert (mOld != null && mNew != null);
-
 	    updateFeatureDiffs(mOld, mNew, true, false);
 	    updateDiffs(mOld.getStability(),
-		diffTypeError(mOld.getError(), mNew.getError()));
+		diffTypeError(mOld.getErrorType(), mNew.getErrorType()));
 	    updateDiffs(mOld.getStability(), diffArgs(mOld.getArguments(),
 		mNew.getArguments()));
 	}
--- a/usr/src/java/adr/org/opensolaris/os/adr/Property.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Property.java	Fri May 06 14:55:38 2011 -0400
@@ -20,28 +20,36 @@
  */
 
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 package org.opensolaris.os.adr;
 
-public class Property extends Feature implements PropertyError {
+public class Property extends Feature {
 
     private boolean readable_;
     private boolean writable_;
-    private Type readError_;
-    private Type writeError_;
+    private ADRError readError_;
+    private ADRError writeError_;
+    private Doc doc_;
 
     public Property(String name, Stability stability, Type t, boolean optional,
-        boolean readable, boolean writable, Type rerror, Type werror) {
+        boolean readable, boolean writable, ADRError rerror,
+	ADRError werror, Doc doc) {
 
-	super(name, stability, t, optional);
+	super(name, stability, t, optional, doc);
 	assert (readable || writable);
 	readable_ = readable;
 	writable_ = writable;
-
 	readError_ = rerror;
 	writeError_ = werror;
+	doc_ = doc;
+    }
+
+    public Property(String name, Stability stability, Type t, boolean optional,
+	boolean readable, boolean writable, ADRError rerror, ADRError werror) {
+	this(name, stability, t, optional, readable, writable, rerror, werror,
+	    null);
     }
 
     public boolean isReadable() {
@@ -52,13 +60,22 @@
 	return writable_;
     }
 
-    @Override
-    public Type getReadError() {
-	return readError_;
+    /*
+     * If the operation cannot fail, the error can be null.
+     */
+    public ADRError getReadError() {
+    	return readError_;
     }
 
-    @Override
-    public Type getWriteError() {
-	return writeError_;
+    public Type getReadErrorType() {
+	return readError_ != null ? readError_.getType() : null;
+    }
+
+    public ADRError getWriteError() {
+     	return writeError_;
+    }
+
+    public Type getWriteErrorType() {
+	return writeError_ != null ? writeError_.getType() : null;
     }
 }
--- a/usr/src/java/adr/org/opensolaris/os/adr/PropertyDiff.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/PropertyDiff.java	Fri May 06 14:55:38 2011 -0400
@@ -20,7 +20,7 @@
  */
 
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 package org.opensolaris.os.adr;
@@ -43,18 +43,17 @@
 	    Property pOld = propsOld.get(pname);
 	    Property pNew = propsNew.get(pname);
 	    assert (pOld != null && pNew != null);
-
 	    boolean reads = pOld.isReadable() && pNew.isReadable();
 	    boolean writes = pOld.isWritable() && pNew.isWritable();
 	    updateFeatureDiffs(pOld, pNew, reads, writes);
 	    updateDiffs(pOld.getStability(), diffAccess(pOld, pNew));
 	    if (reads) {
-		updateDiffs(pOld.getStability(),
-		    diffTypeError(pOld.getReadError(), pNew.getReadError()));
+		updateDiffs(pOld.getStability(), diffTypeError(
+		    pOld.getReadErrorType(), pNew.getReadErrorType()));
 	    }
 	    if (writes) {
-		updateDiffs(pOld.getStability(),
-		    diffTypeError(pOld.getWriteError(), pNew.getWriteError()));
+		updateDiffs(pOld.getStability(), diffTypeError(
+		    pOld.getWriteErrorType(), pNew.getWriteErrorType()));
 	    }
 	}
     }
--- a/usr/src/java/adr/org/opensolaris/os/adr/PropertyError.java	Thu May 05 13:16:34 2011 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-
-package org.opensolaris.os.adr;
-
-public interface PropertyError {
-    /**
-     * Obtains the type of error returned by the getter of the given property.
-     * Must be a subclass of {@code Type.ComplexType}, with two exceptions.
-     * If this returns {@code null}, the operation can't fail.
-     * If this returns {@code StdType.VOID}, the operation may fail but
-     * errors don't include structured data.
-     *
-     * @return the error type
-     */
-    Type getReadError();
-
-    /**
-     * Obtains the type of error returned by the setter of the given property.
-     * Must be a subclass of {@code Type.ComplexType}, with two exceptions.
-     * If this returns {@code null}, the operation can't fail.
-     * If this returns {@code StdType.VOID}, the operation may fail but
-     * errors don't include structured data.
-     *
-     * @return the error type
-     */
-    Type getWriteError();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Result.java	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,45 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ */
+
+package org.opensolaris.os.adr;
+
+
+public class Result extends SimpleHasType {
+
+    private Doc doc_;
+
+    public Result(Type type, boolean optional, Doc doc) {
+	super(type, optional);
+	doc_ = doc;
+    }
+
+    public Result(Type type, boolean optional) {
+	this(type, optional, null);
+    }
+
+    public Doc getDoc() {
+	return doc_;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/SimpleHasType.java	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,54 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ */
+
+package org.opensolaris.os.adr;
+
+public class SimpleHasType implements HasType {
+
+    protected Type type_;
+    protected boolean optional_;
+
+    public SimpleHasType(Type t, boolean optional) {
+	type_ = t;
+	optional_ = optional;
+	if (t != null && t.getSource() == Type.Source.FORWARD)
+	    ((Type.ForwardType)t).addReference(this);
+    }
+
+    @Override
+    public Type getType() {
+	return type_;
+    }
+
+    @Override
+    public void setType(Type type) {
+	type_ = type;
+    }
+
+    @Override
+    public boolean isOptional() {
+	return optional_;
+    }
+}
--- a/usr/src/java/adr/org/opensolaris/os/adr/Type.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/Type.java	Fri May 06 14:55:38 2011 -0400
@@ -48,7 +48,7 @@
 
 	@Override
 	public String toString() {
-	    return type_.toString();
+	    return type_.toString().toLowerCase();
 	}
     }
 
@@ -81,13 +81,20 @@
     public static class ComplexType extends DefinedType {
 	private List<Field> fields_;
 	private List<ComplexType> parents_;
+	private Doc doc_;
 
 	public ComplexType(String name, List<Field> fields,
-	    List<ComplexType> parents) {
+	    List<ComplexType> parents, Doc doc) {
 
 	    super(Source.COMPLEX, name);
 	    fields_ = fields;
 	    parents_ = parents;
+	    doc_ = doc;
+	}
+
+	public ComplexType(String name, List<Field> fields,
+	    List<ComplexType> parents) {
+	    this(name, fields, parents, null);
 	}
 
 	public List<Field> getFields() {
@@ -98,6 +105,10 @@
 	    return parents_;
 	}
 
+	public Doc getDoc() {
+	    return doc_;
+	}
+
 	public List<Field> getAllFields() {
 	    if (parents_ == null)
 		return fields_;
@@ -134,10 +145,16 @@
     public static class EnumValue {
 	private String name_;
 	private int value_;
+	private Doc doc_;
+
+	public EnumValue(String name, int value, Doc doc) {
+	    name_ = name;
+	    value_ = value;
+	    doc_ = doc;
+	}
 
 	public EnumValue(String name, int value) {
-	    name_ = name;
-	    value_ = value;
+	    this(name, value, null);
 	}
 
 	public String getName() {
@@ -147,16 +164,28 @@
 	public int getValue() {
 	    return value_;
 	}
+
+	public Doc getDoc() {
+	    return doc_;
+	}
     }
 
     public static class EnumType extends DefinedType {
 	private List<EnumValue> values_;
 	private EnumValue fallback_;
+	private Doc doc_;
 
-	public EnumType(String name, List<EnumValue> values, String fallback) {
+	public EnumType(String name, List<EnumValue> values, EnumValue fallback,
+	    Doc doc) {
 	    super(Source.ENUM, name);
 	    values_ = values;
-	    fallback_ = fallback != null ? new EnumValue(fallback, 0) : null;
+	    fallback_ = fallback;
+	    doc_ = doc;
+	}
+
+	public EnumType(String name, List<EnumValue> values,
+	    EnumValue fallback) {
+	    this(name, values, fallback, null);
 	}
 
 	public List<EnumValue> getValues() {
@@ -167,6 +196,10 @@
 	    return fallback_;
 	}
 
+	public Doc getDoc() {
+	    return doc_;
+	}
+
 	@Override
 	public String toString() {
 	    return "enum " + getName();
@@ -182,21 +215,24 @@
 		((Type.ForwardType)type).addReference(this);
 	}
 
+	@Override
 	public void setType(Type type) {
 	    type_ = type;
 	}
 
+	@Override
 	public Type getType() {
 	    return (type_);
 	}
 
+	@Override
 	public boolean isOptional() {
 	    return false;
 	}
 
 	@Override
 	public String toString() {
-	    return "array of " + type_.toString();
+	    return type_.toString() + "[]";
 	}
     }
 
--- a/usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRGen.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRGen.java	Fri May 06 14:55:38 2011 -0400
@@ -35,6 +35,7 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.TransformerException;
 import javax.xml.validation.SchemaFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -45,6 +46,9 @@
 import org.xml.sax.SAXParseException;
 
 public class ADRGen {
+    private static final String ADRGEN_USAGE = "Usage: adrgen [-N]" +
+	" [-c [-r [-m][-s]]] [-j dir [-i]] [-o {docbook | text | none}]" +
+	" [-d baseline.xml] spec.xml";
     private static final EnumSet<StdType> NULLABLE = EnumSet.of(
 	StdType.STRING, StdType.OBJECT, StdType.OPAQUE, StdType.PASSWORD);
 
@@ -55,6 +59,7 @@
     Map<String, String> pragmas_ = new HashMap<String, String>();
     String basename_;
     Interface iface_;
+    Document doc_;
 
     private boolean checkNullable_ = true;
 
@@ -194,8 +199,8 @@
 	if (optional && !validOptional(type))
 	    throw new ParseException("Field \"" + name +
 		"\" specifies invalid optional type: " + type);
-
-	return new Field(name, type, optional);
+	Doc doc = parseDocElements(field);
+	return new Field(name, type, optional, doc);
     }
 
     private Stability parseStability(Element e) throws ParseException {
@@ -259,8 +264,9 @@
 	List<Field> fields = new LinkedList<Field>();
 	List<Type.ComplexType> parents = new LinkedList<Type.ComplexType>();
 	Set<String> names = new HashSet<String>();
+	Doc tdoc = parseDocElements(type);
+
 	for (Element e : getChildElements(type)) {
-	    parseDocChildren(e);
 	    String nname = e.getNodeName();
 	    if (nname.equals("field")) {
 		Field f = parseField(e);
@@ -271,14 +277,13 @@
 	    } else if (nname.equals("include")) {
 		assert (fields.size() == 0);  /* Schema enforced */
 		parents.add(parseInclude(e, iface_.types_));
-	    } else if (nname.equals("doc") || nname.equals("summary")) {
-		parseDoc(e);
-	    } else {
+	    } else if (!nname.equals("doc") && !nname.equals("summary")) {
 		throw new ParseException("UNKNOWN ELEMENT: " + nname);
 	    }
 	}
 
-	Type.ComplexType newtype = new Type.ComplexType(name, fields, parents);
+	Type.ComplexType newtype = new Type.ComplexType(
+	    name, fields, parents, tdoc);
 
 	/*
 	 * Since we only look up types in forwardTypes if we don't find
@@ -306,17 +311,16 @@
     private Type.EnumType parseEnum(Element type) throws ParseException {
 
 	String name = type.getAttribute("name");
+	Doc edoc = parseDocElements(type);
 
 	List<Type.EnumValue> values = new LinkedList<Type.EnumValue>();
 	int nextValue = 0;
-	String fallback = null;
+	Type.EnumValue fallback = null;
 	for (Element e : getChildElements(type)) {
-	    parseDocChildren(e);
 	    String nname = e.getNodeName();
 	    if (nname.equals("value")) {
 		String ename = e.getAttribute("name");
 		int value = nextValue++;
-
 		String eval = e.getAttribute("value");
 		if (eval.length() > 0) {
 		    try {
@@ -326,21 +330,23 @@
 			throw new ParseException("bogus enum value: " + eval);
 		    }
 		}
-		values.add(new Type.EnumValue(ename, value));
+		Doc vdoc = parseDocElements(e);
+		values.add(new Type.EnumValue(ename, value, vdoc));
 	    } else if (nname.equals("fallback")) {
 		if (fallback != null)
 		    throw new ParseException(String.format(
 			"enum \"%s\" specifies multiple fallback values",
 			name));
-		fallback = e.getAttribute("name");
-	    } else if (nname.equals("doc") || nname.equals("summary")) {
-		parseDoc(e);
-	    } else {
+		String fname = e.getAttribute("name");
+		Doc fdoc = parseDocElements(e);
+		fallback = new Type.EnumValue(fname, 0, fdoc);
+	    } else if (!nname.equals("doc") && !nname.equals("summary")) {
 		throw new ParseException("UNKNOWN ELEMENT: " + nname);
 	    }
 	}
 
-	Type.EnumType newtype = new Type.EnumType(name, values, fallback);
+	Type.EnumType newtype = new Type.EnumType(name, values, fallback,
+	    edoc);
 
 	Type.ForwardType ft = forwardTypes_.remove(name);
 	if (ft != null) {
@@ -368,10 +374,9 @@
 	Map<String, Method> methods = new TreeMap<String, Method>();
 	Map<String, Event> events = new TreeMap<String, Event>();
 	List<API> parents = new LinkedList<API>();
+	Doc adoc = parseDocElements(type);
 
-	parseDocChildren(type);
 	for (Element e : getChildElements(type)) {
-	    parseDocChildren(e);
 	    String nname = e.getNodeName();
 	    if (nname.equals("version")) {
 		int major = -1;
@@ -409,16 +414,16 @@
 		boolean both = access.equals("rw");
 		boolean writable = both || access.equals("wo");
 		boolean readable = both || access.equals("ro");
+		Doc pdoc = parseDocElements(e);
 
 		if (optional && !validOptional(t))
 		    throw new ParseException("Property \"" + pname +
 			"\" specifies invalid optional type: " + type);
 
 		// process error elements
-		Type readError = null;
-		Type writeError = null;
+		ADRError readError = null;
+		ADRError writeError = null;
 		for (Element f : getChildElements(e, "error")) {
-		    parseDocChildren(f);
 		    String efor = f.getAttribute("for");
 		    if ((efor == null) || (efor.trim().length() == 0))
 			efor = access;
@@ -429,44 +434,45 @@
 
 		    if (efor.equals("rw") && access.equals("rw")) {
 			if ((readError != null) || (writeError != null))
-				throw new ParseException("A read or write " +
-				    "error is already assigned to this " +
-				    "property - " + pname);
+			    throw new ParseException("A read or write error " +
+				"is already assigned to this property - " +
+				pname);
 
-			writeError = theError;
-			readError = theError;
+			Doc doc = parseDocElements(f);
+			readError = writeError = new ADRError(theError, doc);
 		    } else if (efor.equals("ro") &&
 			(access.equals("rw") || access.equals("ro"))) {
 			if (readError != null)
-				throw new ParseException("A read error is " +
-				    "already assigned to this property - " +
-				    pname);
+			    throw new ParseException("A read error is " +
+				"already assigned to this property - " + pname);
 
-			readError = theError;
+			Doc doc = parseDocElements(f);
+			readError = new ADRError(theError, doc);
 		    } else if (efor.equals("wo") &&
 			(access.equals("rw") || access.equals("wo"))) {
 			if (writeError != null)
-				throw new ParseException("A write error is " +
-				    "already assigned to this property - " +
-				    pname);
+			    throw new ParseException("A write error is " +
+				"already assigned to this property - " + pname);
 
-			writeError = theError;
+			Doc doc = parseDocElements(f);
+			writeError = new ADRError(theError, doc);
 		    } else {
 			throw new ParseException(efor + " error cannot be " +
-			    " assigned to a " + access + " property." + pname);
+			    "assigned to a " + access + " property - " + pname);
 		    }
 		}
-		props.put(pname, new Property(pname, stability, t, optional,
-		    readable, writable, readError, writeError));
+		Property prop = new Property(pname, stability, t, optional,
+		    readable, writable, readError, writeError, pdoc);
+		props.put(pname, prop);
 	    } else if (nname.equals("method")) {
 		List<Argument> args = new LinkedList<Argument>();
 		String mname = e.getAttribute("name");
 		Stability stability = parseStability(e);
-		Type result = null;
-		Type error = null;
-		boolean optresult = false;
+		Result result = null;
+		ADRError error = null;
+		Doc mdoc = parseDocElements(e);
+
 		for (Element f : getChildElements(e)) {
-		    parseDocChildren(f);
 		    String nnname = f.getNodeName();
 		    if (nnname.equals("result")) {
 			if (result != null)
@@ -479,14 +485,14 @@
 			    throw new ParseException("Method \"" + mname +
 				"\" specifies invalid optional return type: " +
 				t);
-
-			result = t;
-			optresult = optional;
+			Doc doc = parseDocElements(f);
+			result = new Result(t, optional, doc);
 		    } else if (nnname.equals("error")) {
 			assert (error == null);  /* Schema enforced */
 			Type.ComplexType t = parseRef(f, iface_.types_);
-			if ((error = t) == null)
-			    error = Type.getType(StdType.VOID);
+			Type etype = t != null ? t : Type.getType(StdType.VOID);
+			Doc doc = parseDocElements(f);
+			error = new ADRError(etype, doc);
 		    } else if (nnname.equals("argument")) {
 			String aname = f.getAttribute("name");
 			Type t = parseTypedOrListed(f);
@@ -495,21 +501,24 @@
 			    throw new ParseException("Method \"" + mname +
 				"\" specifies invalid optional argument type: "
 				+ t);
-			args.add(new Argument(aname, t, optional));
+			Doc doc = parseDocElements(f);
+			args.add(new Argument(aname, t, optional, doc));
 		    }
 		}
 		if (result == null)
-		    result = Type.getType(StdType.VOID);
-		methods.put(mname, new Method(mname, stability, result,
-		    optresult, args, error));
+		    result = new Result(Type.getType(StdType.VOID), false);
+		Method meth = new Method(mname, stability, result, args, error,
+		    mdoc);
+		methods.put(mname, meth);
 	    } else if (nname.equals("event")) {
 		String ename = e.getAttribute("name");
+		Doc edoc = parseDocElements(e);
 		events.put(ename, new Event(ename, parseStability(e),
-		    parseTypedOrListed(e)));
+		    parseTypedOrListed(e), edoc));
 	    }
 	}
 
-	API api = new API(name, vers, props, methods, events, parents);
+	API api = new API(name, vers, props, methods, events, parents, adoc);
 	if (!iface_.addAPI(api))
 	    throw new ParseException("API redefined: " + name);
 
@@ -530,18 +539,15 @@
 	pragmas_.put(domain + ":" + name, value);
     }
 
-    private void parseDoc(Element doc) {
-	/* Do nothing for now */
-	return;
-    }
+    private Doc parseDocElements(Element parent)
+	throws ParseException {
 
-    private void parseDocChildren(Element e) throws ParseException {
-	Element doc;
-	if ((doc = getSingleChild(e, "summary", false)) != null)
-	    parseDoc(doc);
-	if ((doc = getSingleChild(e, "doc", false)) != null)
-	    parseDoc(doc);
-	return;
+	Element esummary = getSingleChild(parent, "summary", false);
+	Element edetail = getSingleChild(parent, "doc", false);
+
+	if (esummary != null || edetail != null)
+	    return new Doc(esummary, edetail);
+	return null;
     }
 
     public ADRGen(DocumentBuilder builder, File file, boolean checkNullable)
@@ -556,17 +562,17 @@
 	/*
 	 * Parse file.
 	 */
-	Document doc = null;
 	try {
-	    doc = builder.parse(file);
+	    doc_ = builder.parse(file);
 	} catch (SAXException ex) {
 	    throw new ParseException(ex.getMessage());
 	} catch (IOException ex) {
 	    throw new ParseException(file + ": read error");
 	}
 
-	Element docelement = doc.getDocumentElement();
+	Element docelement = doc_.getDocumentElement();
 	iface_ = new Interface(docelement.getAttribute("name"));
+	iface_.setDoc(parseDocElements(docelement));
 
 	/* XXX: get data from document element */
 
@@ -581,9 +587,7 @@
 		parseApi(e);
 	    } else if (nname.equals("pragma")) {
 		parsePragma(e);
-	    } else if (nname.equals("doc") || nname.equals("summary")) {
-		parseDoc(e);
-	    } else {
+	    } else if (!nname.equals("doc") && !nname.equals("summary")) {
 		throw new ParseException("UNKNOWN NODE: " + nname);
 	    }
 	}
@@ -686,11 +690,12 @@
 	boolean generate_diff = false;
 	boolean generate_common = false;
 	boolean check_nullable = true;
+	DocGenerator.Format doc_fmt = null;
 	String java_dir = "java";
 	String baseline = "";
 
 	List<Option> opts = new LinkedList<Option>();
-	int operands = getOptions(args, "Ncj:mrsid:", opts);
+	int operands = getOptions(args, "Ncj:mrsid:o:", opts);
 	for (Option o : opts) {
 	    switch (o.getLetter()) {
 	    case 'N':
@@ -719,13 +724,22 @@
 	    case 'm':
 		generate_common = true;
 		break;
+	    case 'o':
+		try {
+		    doc_fmt =
+			DocGenerator.Format.valueOf(o.getArg().toUpperCase());
+		} catch (IllegalArgumentException ie) {
+		    System.err.format("Invalid documentation format: %s\n",
+			o.getArg());
+		    System.err.println(ADRGEN_USAGE);
+		    System.exit(2);
+		}
+		break;
 	    }
 	}
 
 	if (operands == args.length) {
-	    System.err.println(
-		"Usage: adrgen [-N] [-c [-r [-m][-s]]] [-j dir [-i]]" +
-		" [-d baseline.xml] spec.xml");
+	    System.err.println(ADRGEN_USAGE);
 	    System.exit(2);
 	}
 
@@ -790,6 +804,9 @@
 			generate_common);
 		if (generate_java)
 		    new JGenerator(p, java_dir).generate(false, generate_jimpl);
+		if (doc_fmt != null) {
+		    DocGenerator.generate(p, doc_fmt);
+		}
 	    } catch (ParseException e) {
 		System.err.format("Error parsing file %s: %s\n", file,
 		    e.getMessage());
@@ -797,6 +814,11 @@
 	    } catch (FileNotFoundException e) {
 		System.err.println(e.getMessage());
 		System.exit(1);
+	    } catch (TransformerException e) {
+		/* Display an error and continue other operations */
+		System.err.format("Error transforming file %s: %s\n", file,
+		    e.getMessage());
+		System.exit(1);
 	    }
 	    builder.reset();
 	    /*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRdocbook.xsl	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,691 @@
+<?xml version="1.0"?>
+<!--
+  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+  
+  CDDL HEADER START
+  
+   The contents of this file are subject to the terms of the
+   Common Development and Distribution License (the "License").
+   You may not use this file except in compliance with the License.
+  
+   You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+   or http://www.opensolaris.org/os/licensing.
+   See the License for the specific language governing permissions
+   and limitations under the License.
+  
+   When distributing Covered Code, include this CDDL HEADER in each
+   file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+   If applicable, add the following below this CDDL HEADER, with the
+   fields enclosed by brackets "[]" replaced with your own identifying
+   information: Portions Copyright [yyyy] [name of copyright owner]
+  
+  CDDL HEADER END
+-->
+
+<xsl:stylesheet version="1.0" xmlns:adr="http://www.opensolaris.org/ns/adr"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+    <!-- Write the opening elements -->
+    <xsl:output method="xml" version="1.0" encoding="UTF-8" 
+	indent="no" omit-xml-declaration="no" standalone="yes" 
+	doctype-public="-//OASIS//DTD DocBook V4.4//EN"
+	doctype-system="http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"/>
+
+    <!-- Locale-specific content -->
+    <xsl:variable name="lang.title"> Interface Documentation</xsl:variable>
+    <xsl:variable name="lang.enumTitle">Enumerated Types</xsl:variable>
+    <xsl:variable name="lang.structTitle">Structure Types</xsl:variable>
+    <xsl:variable name="lang.apiTitle">APIs</xsl:variable>
+    <xsl:variable name="lang.intfHead">interface </xsl:variable>
+    <xsl:variable name="lang.enumLabel">enum </xsl:variable>
+    <xsl:variable name="lang.fbLabel">fallback </xsl:variable>
+    <xsl:variable name="lang.structLabel">struct </xsl:variable>
+    <xsl:variable name="lang.apiHead">api </xsl:variable>
+    <xsl:variable name="lang.propHead"> Properties</xsl:variable>
+    <xsl:variable name="lang.methHead"> Methods</xsl:variable>
+    <xsl:variable name="lang.evHead"> Events</xsl:variable>
+    <xsl:variable name="lang.verLabel">Version - </xsl:variable>
+    <xsl:variable name="lang.incApiHead">from included </xsl:variable>
+    <xsl:variable name="lang.propLabel">property </xsl:variable>
+    <xsl:variable name="lang.typeLabel">Type: </xsl:variable>
+    <xsl:variable name="lang.roLabel">Read </xsl:variable>
+    <xsl:variable name="lang.woLabel">Write </xsl:variable>
+    <xsl:variable name="lang.rwLabel">Read-Write </xsl:variable>
+    <xsl:variable name="lang.roProp">R/O </xsl:variable>
+    <xsl:variable name="lang.woProp">W/O </xsl:variable>
+    <xsl:variable name="lang.rwProp">R/W </xsl:variable>
+    <xsl:variable name="lang.errLabel">Error: </xsl:variable>
+    <xsl:variable name="lang.methLabel">method </xsl:variable>
+    <xsl:variable name="lang.argLabel">Arguments: </xsl:variable>
+    <xsl:variable name="lang.resLabel">Result: </xsl:variable>
+    <xsl:variable name="lang.evLabel">event </xsl:variable>
+    <xsl:variable name="lang.voidLabel">void</xsl:variable>
+    <xsl:variable name="lang.optLabel">optional</xsl:variable>
+
+    <xsl:strip-space elements="*"/>
+
+    <xsl:template match="/">
+      <article>
+	<xsl:apply-templates/>
+      </article>
+    </xsl:template>
+
+    <!-- Process the interface element -->
+    <xsl:template match="adr:interface">
+      <!-- Write out a heading -->
+      <section>
+	<title>
+	  <xsl:value-of select="@name"/><xsl:value-of select="$lang.title"/>
+	</title>
+	<para>
+	  <emphasis role="strong">
+	    <xsl:value-of select="$lang.intfHead"/><xsl:value-of select="@name"/>
+	  </emphasis>
+	  <xsl:apply-templates select="adr:summary"/>
+	</para>
+	<xsl:apply-templates select="adr:doc"/>
+
+	<!-- Process the enum elements, if any -->
+	<xsl:if test="adr:enum">
+	  <section>
+	    <title><xsl:value-of select="$lang.enumTitle"/></title>
+	    <xsl:apply-templates select="adr:enum"/>
+	  </section>
+	</xsl:if>
+
+	<!-- Process the type elements, if any -->
+	<xsl:if test="adr:type">
+	  <section>
+	    <title><xsl:value-of select="$lang.structTitle"/></title>
+	    <xsl:apply-templates select="adr:type"/>
+	  </section>
+	</xsl:if>
+
+	<!-- Process the api elements, if any -->
+	<xsl:if test="adr:api">
+	  <section>
+	    <title><xsl:value-of select="$lang.apiTitle"/></title>
+	    <xsl:apply-templates select="adr:api"/>
+	  </section>
+	</xsl:if>
+
+      </section>
+    </xsl:template>
+
+    <!-- Process the enum, enum value, enum fallback elements -->
+    <xsl:template match="adr:interface/adr:enum">
+      <para>
+	<xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
+	<emphasis role="strong">
+	  <xsl:value-of select="$lang.enumLabel"/>
+	  <type><xsl:value-of select="@name"/></type>
+	</emphasis>
+	<xsl:apply-templates select="adr:summary|adr:doc"/>
+	<simplelist type="vert">
+	  <xsl:call-template name="tenum"/>
+	  <xsl:apply-templates select="adr:fallback"/>
+	</simplelist>
+      </para>
+    </xsl:template>
+
+    <!-- Process all the enum value elements -->
+    <xsl:template name="tenum">
+      <xsl:param name="thenode" select="adr:value[1]"/>
+      <xsl:param name="initval" select="0"/>
+      <xsl:variable name="currvalue">
+	<xsl:choose>
+          <xsl:when test="$thenode/@value">
+            <xsl:value-of select="$thenode/@value"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$initval"/>
+          </xsl:otherwise>
+	</xsl:choose>           
+      </xsl:variable>
+      <member>
+	<xsl:value-of select="$thenode/@name"/>
+	<xsl:text> (</xsl:text>
+	<literal moreinfo="none">
+	  <xsl:value-of select="$currvalue"/>
+	</literal>
+	<xsl:text>)</xsl:text>
+	<xsl:apply-templates select="$thenode/adr:summary"/>
+	<xsl:apply-templates select="$thenode/adr:doc" mode="indent"/>
+      </member>
+      <xsl:if test="$thenode/following-sibling::adr:value[1]">
+	<xsl:call-template name="tenum">
+	  <xsl:with-param name="thenode" 
+	    select="$thenode/following-sibling::adr:value[1]"/>
+	  <xsl:with-param name="initval" select="$currvalue + 1"/>
+	</xsl:call-template>
+      </xsl:if>
+    </xsl:template>
+    
+    <!-- Process the enum fallback elements -->
+    <xsl:template match="adr:enum/adr:fallback">
+      <member>
+	<xsl:value-of select="$lang.fbLabel"/>
+	<xsl:text>(</xsl:text>
+	<xsl:value-of select="@name"/>
+	<xsl:text>)</xsl:text>
+	<xsl:apply-templates select="adr:summary"/>
+	<xsl:apply-templates select="adr:doc" mode="indent"/>
+      </member>
+    </xsl:template>
+
+    <!-- Process the type (struct), type field, include elements -->
+    <xsl:template match="adr:interface/adr:type">
+      <para>
+	<xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
+	<emphasis role="strong">
+	  <xsl:value-of select="$lang.structLabel"/>
+	  <structname><xsl:value-of select="@name"/></structname>
+	</emphasis>
+	<xsl:apply-templates select="adr:summary|adr:doc"/>
+	<simplelist type="vert">
+	  <xsl:apply-templates select="adr:include"/>
+	  <xsl:apply-templates select="adr:field"/>
+	</simplelist>
+      </para>
+    </xsl:template>
+
+    <!-- Process the include elements within a type definition -->
+    <xsl:template match="adr:type/adr:include">
+      <xsl:apply-templates select="//adr:type[@name = current()/@typeref]"
+	  mode="include"/>
+    </xsl:template>
+    
+    <!-- Process the type field elements -->
+    <xsl:template match="adr:type/adr:field">
+      <member>
+	<xsl:call-template name="ttype"/>
+	<xsl:text> </xsl:text>
+	<structfield><xsl:value-of select="@name"/></structfield>
+	<xsl:call-template name="topt"/>
+	<xsl:apply-templates select="adr:summary"/>
+	<xsl:apply-templates select="adr:doc" mode="indent"/>
+      </member>
+    </xsl:template>
+
+    <!-- Process included type elements -->
+    <xsl:template match="adr:type" mode="include">
+      <xsl:apply-templates select="adr:field"/>
+    </xsl:template>
+
+    <!-- Process the api, api property, api method, api event elements -->
+    <xsl:template match="adr:interface/adr:api">
+      <section>
+	<title>
+	  <xsl:attribute name="id">
+	    <xsl:value-of select="concat('api', @name)"/>
+	  </xsl:attribute>
+	  <xsl:value-of select="$lang.apiHead"/><xsl:value-of select="@name"/>
+	</title>
+	<para>
+	  <emphasis role="strong">
+	    <xsl:value-of select="$lang.apiHead"/><xsl:value-of select="@name"/>
+	  </emphasis>
+	  <xsl:apply-templates select="adr:summary|adr:doc"/>
+	</para>
+
+	<!-- Process the version elements, if any -->
+	<xsl:apply-templates select="adr:version[position() = 1]"/>
+
+	<!-- Save the "included" api, if any -->
+	<xsl:variable name="incApi" 
+	    select="//adr:api[@name = current()/adr:include/@typeref]"/>
+
+	<!-- Process the api properties, if any -->
+	<xsl:if test="adr:property">
+	  <section>
+	    <title>
+	      <xsl:value-of select="@name"/>
+	      <xsl:value-of select="$lang.propHead"/>
+	    </title>
+	    <xsl:apply-templates select="adr:property"/>
+	  </section>
+	</xsl:if>
+
+	<!-- Process the included api properties, if any -->
+	<xsl:if test="$incApi/adr:property">
+	  <section>
+	    <title>
+	      <xsl:value-of select="@name"/>
+	      <xsl:value-of select="$lang.propHead"/>
+	      <xsl:text> (</xsl:text>
+	      <xsl:value-of select="$lang.incApiHead"/>
+	      <link>
+		<xsl:attribute name="linkend">
+		  <xsl:value-of 
+		    select="concat('api', current()/adr:include/@typeref)"/>
+		</xsl:attribute>
+		<xsl:value-of select="$lang.apiHead"/>
+		<xsl:value-of select="current()/adr:include/@typeref"/>
+	      </link>
+	      <xsl:text>)</xsl:text>
+	    </title>
+	    <xsl:apply-templates select="$incApi/adr:property"/>
+	  </section>
+	</xsl:if>
+
+	<!-- Process the api methods, if any -->
+	<xsl:if test="adr:method">
+	  <section>
+	    <title>
+	      <xsl:value-of select="@name"/>
+	      <xsl:value-of select="$lang.methHead"/>
+	    </title>
+	    <xsl:apply-templates select="adr:method"/>
+	  </section>
+	</xsl:if>
+
+	<!-- Process the included api methods, if any -->
+	<xsl:if test="$incApi/adr:method">
+	  <section>
+	    <title>
+	      <xsl:value-of select="@name"/>
+	      <xsl:value-of select="$lang.methHead"/>
+	      <xsl:text> (</xsl:text>
+	      <xsl:value-of select="$lang.incApiHead"/>
+	      <link>
+		<xsl:attribute name="linkend">
+		  <xsl:value-of
+		    select="concat('api', current()/adr:include/@typeref)"/>
+		</xsl:attribute>
+		<xsl:value-of select="$lang.apiHead"/>
+		<xsl:value-of select="current()/adr:include/@typeref"/>
+	      </link>
+	      <xsl:text>)</xsl:text>
+	    </title>
+	    <xsl:apply-templates select="$incApi/adr:method"/>
+	  </section>
+	</xsl:if>
+
+	<!-- Process the api events, if any -->
+	<xsl:if test="adr:event">
+	  <section>
+	    <title>
+	      <xsl:value-of select="@name"/>
+	      <xsl:value-of select="$lang.evHead"/>
+	    </title>
+	    <xsl:apply-templates select="adr:event"/>
+	  </section>
+	</xsl:if>
+
+	<!-- Process the included api events, if any -->
+	<xsl:if test="$incApi/adr:event">
+	  <section>
+	    <title>
+	      <xsl:value-of select="@name"/>
+	      <xsl:value-of select="$lang.evHead"/>
+	      <xsl:text> (</xsl:text>
+	      <xsl:value-of select="$lang.incApiHead"/>
+	      <link>
+		<xsl:attribute name="linkend">
+		  <xsl:value-of 
+		    select="concat('api', current()/adr:include/@typeref)"/>
+		</xsl:attribute>
+		<xsl:value-of select="$lang.apiHead"/>
+		<xsl:value-of select="current()/adr:include/@typeref"/>
+	      </link>
+	      <xsl:text>)</xsl:text>
+	    </title>
+	    <xsl:apply-templates select="$incApi/adr:event"/>
+	  </section>
+	</xsl:if>
+
+      </section>
+    </xsl:template>
+
+    <!-- Process api version elements -->
+    <xsl:template match="adr:api/adr:version">
+      <para>
+	<xsl:value-of select="$lang.verLabel"/>
+	<xsl:for-each select="parent::node()/adr:version">
+	  <xsl:value-of select="@stability"/>
+	  <xsl:text>(</xsl:text>
+	  <xsl:value-of select="@major"/>
+	  <xsl:text>.</xsl:text>
+	  <xsl:value-of select="@minor"/>
+	  <xsl:text>)</xsl:text>
+	  <xsl:if test="position() != last()">, </xsl:if>
+	</xsl:for-each>
+      </para>
+    </xsl:template>
+
+    <!-- Process the property, property error elements -->
+    <xsl:template match="adr:property">
+      <para>
+	<emphasis role="strong">
+	  <xsl:call-template name="taccess"/>
+	  <xsl:value-of select="$lang.propLabel"/>
+	  <xsl:value-of select="@name"/>
+	</emphasis>
+	<xsl:apply-templates select="adr:summary|adr:doc"/>
+	<simplelist type="vert">
+	  <member>
+	    <xsl:value-of select="$lang.typeLabel"/>
+	    <xsl:call-template name="ttype"/>
+	    <xsl:call-template name="topt"/>
+	  </member>
+	  <xsl:apply-templates select="adr:error"/>
+	</simplelist>
+      </para>
+    </xsl:template>
+
+    <!-- Process the property error elements -->
+    <xsl:template match="adr:property/adr:error">
+      <member>
+	<xsl:choose>
+	  <xsl:when test="@for='ro' or parent::node()/@access='ro'">
+	    <xsl:value-of select="$lang.roLabel"/>
+	  </xsl:when>
+	  <xsl:when test="@for='wo' or parent::node()/@access='wo'">
+	    <xsl:value-of select="$lang.woLabel"/>
+	  </xsl:when>
+	  <xsl:when test="@for='rw' or parent::node()/@access='rw'">
+	    <xsl:value-of select="$lang.rwLabel"/>
+	  </xsl:when>
+	</xsl:choose>
+	<xsl:value-of select="$lang.errLabel"/>
+	<xsl:call-template name="ttype"/>
+	<xsl:apply-templates select="adr:summary"/>
+	<xsl:apply-templates select="adr:doc" mode="indent"/>
+      </member>
+    </xsl:template>
+    
+    <!-- Process the method, argument, result, error elements  -->
+    <xsl:template match="adr:api/adr:method">
+      <para>
+	<emphasis role="strong">
+	  <xsl:value-of select="$lang.methLabel"/>
+	  <xsl:value-of select="@name"/>
+	  <xsl:text>(</xsl:text>
+	  <xsl:if test="count(adr:argument) = 0">
+	    <xsl:text> </xsl:text>	    
+	  </xsl:if>
+	  <xsl:for-each select="adr:argument">
+	    <xsl:value-of select="@name"/>
+	    <xsl:if test="position() != last()">, </xsl:if>
+	  </xsl:for-each>
+	  <xsl:text>)</xsl:text>
+	</emphasis>
+	<xsl:apply-templates select="adr:summary|adr:doc"/>
+	<xsl:if test="count(adr:argument) > 0">
+	  <simplelist type="vert">
+	    <member>
+	      <para>
+	      <xsl:value-of select="$lang.argLabel"/>
+	      </para>
+	      <xsl:apply-templates select="adr:argument"/>
+	    </member>
+	  </simplelist>
+	</xsl:if>
+	<xsl:if test="count(adr:result) > 0">
+	  <simplelist type="vert">
+	    <member>
+	      <para>
+	      <xsl:value-of select="$lang.resLabel"/>
+	      </para>
+	      <xsl:apply-templates select="adr:result"/>
+	    </member>
+	  </simplelist>
+	</xsl:if>
+	<xsl:if test="count(adr:error) > 0">
+	  <simplelist type="vert">
+	    <member>
+	      <para>
+	      <xsl:value-of select="$lang.errLabel"/>
+	      </para>
+	      <xsl:apply-templates select="adr:error"/>
+	    </member>
+	  </simplelist>
+	</xsl:if>
+      </para>
+    </xsl:template>
+
+    <!-- Process the method argument elements -->
+    <xsl:template match="adr:method/adr:argument">
+      <para>
+	<xsl:call-template name="ttype"/>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="@name"/>
+	<xsl:call-template name="topt"/>
+	<xsl:apply-templates select="adr:summary"/>
+	<xsl:apply-templates select="adr:doc" mode="indent"/>
+	</para>
+    </xsl:template>
+
+    <!-- Process the method result elements -->
+    <xsl:template match="adr:method/adr:result">
+      <para>
+	<xsl:call-template name="ttype"/>
+	<xsl:call-template name="topt"/>
+	<xsl:apply-templates select="adr:summary"/>
+	<xsl:apply-templates select="adr:doc" mode="indent"/>
+	</para>
+    </xsl:template>
+
+    <!-- Process the method error elements -->
+    <xsl:template match="adr:method/adr:error">
+      <para>
+	<xsl:call-template name="ttype"/>
+	<xsl:apply-templates select="adr:summary"/>
+	<xsl:apply-templates select="adr:doc" mode="indent"/>
+	</para>
+    </xsl:template>
+
+    <!-- Process the event elements -->
+    <xsl:template match="adr:api/adr:event">
+      <para>
+	<emphasis role="strong">
+	  <xsl:value-of select="$lang.evLabel"/>
+	  <xsl:value-of select="@name"/>
+	</emphasis>
+	<xsl:apply-templates select="adr:summary|adr:doc"/>
+	<simplelist type="vert">
+	  <member>
+	    <xsl:value-of select="$lang.typeLabel"/>
+	    <xsl:call-template name="ttype"/>
+	  </member>
+	</simplelist>
+      </para>
+    </xsl:template>
+
+    <!-- Named Templates -->
+    <!-- Process type definition for structs fields, props, methods, events -->
+    <xsl:template name="ttype">
+      <xsl:choose>
+	<xsl:when test="@type">
+	  <type><xsl:value-of select="@type"/></type>
+	</xsl:when>
+	<xsl:when test="@typeref">
+	    <type>
+	      <link>
+		<xsl:attribute name="linkend">
+		  <xsl:value-of select="@typeref"/>
+		</xsl:attribute>
+		<xsl:apply-templates 
+		 select="(//adr:type|//adr:enum)[@name = current()/@typeref]"
+		 mode="refclass"/>
+		<xsl:value-of select="@typeref"/>
+	      </link>
+	    </type>
+	</xsl:when>
+	<xsl:when test="adr:list/@type">
+	  <type>
+	    <xsl:value-of select="adr:list/@type"/><xsl:text>[]</xsl:text>
+	  </type>
+	</xsl:when>
+	<xsl:when test="adr:list/@typeref">
+	    <type>
+	      <link>
+		<xsl:attribute name="linkend">
+		  <xsl:value-of select="adr:list/@typeref"/>
+		</xsl:attribute>
+		<xsl:apply-templates select=
+		  "(//adr:type|//adr:enum)[@name = current()/adr:list/@typeref]"
+		  mode="refclass"/>
+		<xsl:value-of select="adr:list/@typeref"/>
+	      </link>
+	      <xsl:text>[]</xsl:text>
+	    </type>
+	</xsl:when>
+	<xsl:otherwise>
+	  <type><xsl:value-of select="$lang.voidLabel"/></type>
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+    <!-- Process optional attribute for fields, props, args, results -->
+    <xsl:template name="topt">
+      <xsl:if test="@optional='true' or @optional='1'">
+	<xsl:text> (</xsl:text>
+	<emphasis><xsl:value-of select="$lang.optLabel"/></emphasis>
+	<xsl:text>)</xsl:text>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process access attribute for properties -->
+    <xsl:template name="taccess">
+      <xsl:choose>
+	<xsl:when test="@access='ro'">
+	  <xsl:value-of select="$lang.roProp"/>
+	</xsl:when>
+	<xsl:when test="@access='wo'">
+	  <xsl:value-of select="$lang.woProp"/>
+	</xsl:when>
+	<xsl:otherwise> <!-- access=rw -->
+	  <xsl:value-of select="$lang.rwProp"/>
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+    <!-- Templates for type specification -->
+    <xsl:template match="adr:enum" mode="refclass">
+      <xsl:value-of select="$lang.enumLabel"/>
+    </xsl:template>
+
+    <xsl:template match="adr:type" mode="refclass">
+      <xsl:value-of select="$lang.structLabel"/>
+    </xsl:template> 
+
+    <!-- Process the documentation summary elements -->
+    <xsl:template match="adr:summary">
+      <xsl:text> &#x2014; </xsl:text> <!-- &mdash; -->
+      <xsl:apply-templates/>
+    </xsl:template>
+
+    <!-- Process the (detail) documentation elements -->
+    <xsl:template match="adr:doc">
+      <xsl:choose>
+	<xsl:when test="child::*[1][self::adr:para]">
+	  <xsl:apply-templates/>
+	</xsl:when>
+	<xsl:otherwise>
+	  <para>
+	    <xsl:apply-templates/>
+	  </para>
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+    <!-- Process the (detail) documentation elements -->
+    <!-- Indent documentation if parent is itself indented -->
+    <xsl:template match="adr:doc" mode="indent">
+      <simplelist type="vert">
+	<member>
+	  <xsl:choose>
+	    <xsl:when test="child::*[1][self::adr:para]">
+	      <xsl:apply-templates/>
+	    </xsl:when>
+	    <xsl:otherwise>
+	      <para>
+		<xsl:apply-templates/>
+	      </para>
+	    </xsl:otherwise>
+	  </xsl:choose>
+	</member>
+      </simplelist>
+    </xsl:template>
+
+    <!-- Process the (inline) code doc elements -->
+    <xsl:template match="adr:summary//adr:code|adr:doc//adr:code">
+      <code>
+	<xsl:apply-templates/>
+      </code>
+    </xsl:template>
+
+    <!-- Process the (inline) strong doc elements -->
+    <xsl:template match="adr:summary//adr:strong|adr:doc//adr:strong">
+      <emphasis role="strong">
+	<xsl:apply-templates/>
+      </emphasis>
+    </xsl:template>
+
+    <!-- Process the (inline) link doc elements -->
+    <xsl:template match="adr:summary//adr:link|adr:doc//adr:link">
+      <ulink>
+	<xsl:attribute name="url">
+	  <xsl:value-of select="@url"/>
+	</xsl:attribute>
+	<xsl:apply-templates/>
+      </ulink>
+    </xsl:template>
+
+    <!-- Process the (inline) br doc elements -->
+    <xsl:template match="adr:summary//adr:br|adr:doc//adr:br">
+      <!-- Need a better way to simulate line breaks! -->
+      <literallayout format="linespecific" class="normal">
+      </literallayout>
+    </xsl:template>
+
+    <!-- Process the (block) heading doc elements -->
+    <xsl:template match="adr:doc/adr:heading">
+      <title>
+	<xsl:apply-templates/>
+      </title>
+    </xsl:template>
+
+    <!-- Process the (block) para doc elements -->
+    <xsl:template match="adr:doc/adr:para">
+      <para>
+	<xsl:apply-templates/>
+      </para>
+    </xsl:template>
+
+    <!-- Process the (block) list doc elements -->
+    <xsl:template match="adr:doc/adr:list">
+      <xsl:choose>
+	<xsl:when test="@type='ordered'">
+	  <orderedlist inheritnum="ignore" continuation="restarts">
+	    <xsl:apply-templates select="adr:item"/>
+	  </orderedlist>
+	</xsl:when>
+	<xsl:otherwise> <!-- default: unordered -->
+	  <itemizedlist>
+	    <xsl:apply-templates select="adr:item"/>
+	  </itemizedlist>
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+    <!-- Process the (block) list item doc elements -->
+    <xsl:template match="adr:list/adr:item">
+      <listitem>
+	<xsl:apply-templates/>
+      </listitem>
+    </xsl:template>
+
+    <!-- Process the (block) example doc elements -->
+    <xsl:template match="adr:doc/adr:example">
+      <example>
+	<xsl:attribute name="label">
+	  <xsl:value-of select="@caption"/>
+	</xsl:attribute>
+	<programlisting format="linespecific">
+	  <xsl:value-of select="self::node()"/>
+	</programlisting>
+      </example>
+    </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRrmdoc.xsl	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+  
+  CDDL HEADER START
+  
+   The contents of this file are subject to the terms of the
+   Common Development and Distribution License (the "License").
+   You may not use this file except in compliance with the License.
+  
+   You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+   or http://www.opensolaris.org/os/licensing.
+   See the License for the specific language governing permissions
+   and limitations under the License.
+  
+   When distributing Covered Code, include this CDDL HEADER in each
+   file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+   If applicable, add the following below this CDDL HEADER, with the
+   fields enclosed by brackets "[]" replaced with your own identifying
+   information: Portions Copyright [yyyy] [name of copyright owner]
+  
+  CDDL HEADER END
+-->
+<!-- Strips documentation elements from ADR interface definitions -->
+<xsl:stylesheet version="1.0" xmlns:adr="http://www.opensolaris.org/ns/adr"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+    <xsl:output method="xml" version="1.0" encoding="UTF-8" 
+	indent="yes" omit-xml-declaration="no" standalone="yes"/>
+    <xsl:strip-space elements="*"/>
+
+    <!-- identity templates -->
+    <xsl:template match="node()|@*">
+        <xsl:copy>
+            <xsl:apply-templates select="@*|node()"/>
+        </xsl:copy>
+    </xsl:template>
+
+    <!-- strip out document elements -->
+    <xsl:template match="adr:summary |adr:doc"/>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/adrgen/ADRtext.xsl	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,787 @@
+<?xml version="1.0"?>
+<!--
+  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+  
+  CDDL HEADER START
+  
+   The contents of this file are subject to the terms of the
+   Common Development and Distribution License (the "License").
+   You may not use this file except in compliance with the License.
+  
+   You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+   or http://www.opensolaris.org/os/licensing.
+   See the License for the specific language governing permissions
+   and limitations under the License.
+  
+   When distributing Covered Code, include this CDDL HEADER in each
+   file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+   If applicable, add the following below this CDDL HEADER, with the
+   fields enclosed by brackets "[]" replaced with your own identifying
+   information: Portions Copyright [yyyy] [name of copyright owner]
+  
+  CDDL HEADER END
+-->
+
+<xsl:stylesheet version="1.0" xmlns:adr="http://www.opensolaris.org/ns/adr"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+    <!-- Write the opening elements -->
+    <xsl:output method="text" version="1.0" encoding="UTF-8" 
+	indent="no" omit-xml-declaration="yes" standalone="yes"/>
+
+    <!-- Locale-specific content -->
+    <xsl:variable name="lang.title">INTERFACE DOCUMENTATION</xsl:variable>
+    <xsl:variable name="lang.enumTitle">Enumerated Types</xsl:variable>
+    <xsl:variable name="lang.structTitle">Structure Types</xsl:variable>
+    <xsl:variable name="lang.apiTitle">APIs</xsl:variable>
+    <xsl:variable name="lang.intfHead">Interface </xsl:variable>
+    <xsl:variable name="lang.enumLabel">enum </xsl:variable>
+    <xsl:variable name="lang.fbLabel">fallback </xsl:variable>
+    <xsl:variable name="lang.structLabel">struct </xsl:variable>
+    <xsl:variable name="lang.apiHead">Api </xsl:variable>
+    <xsl:variable name="lang.propHead">Properties</xsl:variable>
+    <xsl:variable name="lang.methHead">Methods</xsl:variable>
+    <xsl:variable name="lang.evHead">Events</xsl:variable>
+    <xsl:variable name="lang.verLabel">Version - </xsl:variable>
+    <xsl:variable name="lang.incApiHead">From Included </xsl:variable>
+    <xsl:variable name="lang.propLabel">Property: </xsl:variable>
+    <xsl:variable name="lang.typeLabel">Type: </xsl:variable>
+    <xsl:variable name="lang.roLabel">Read </xsl:variable>
+    <xsl:variable name="lang.woLabel">Write </xsl:variable>
+    <xsl:variable name="lang.rwLabel">Read-Write </xsl:variable>
+    <xsl:variable name="lang.roProp">Read-Only</xsl:variable>
+    <xsl:variable name="lang.woProp">Write-Only</xsl:variable>
+    <xsl:variable name="lang.rwProp">Read-Write</xsl:variable>
+    <xsl:variable name="lang.errLabel">Error:</xsl:variable>
+    <xsl:variable name="lang.methLabel">Method: </xsl:variable>
+    <xsl:variable name="lang.argLabel">Arguments:</xsl:variable>
+    <xsl:variable name="lang.resLabel">Result:</xsl:variable>
+    <xsl:variable name="lang.evLabel">Event: </xsl:variable>
+    <xsl:variable name="lang.voidLabel">void</xsl:variable>
+    <xsl:variable name="lang.optLabel">Optional</xsl:variable>
+
+    <xsl:variable name="indentstr" select="'             '"/>
+
+    <xsl:strip-space elements="*"/>
+
+    <xsl:template match="text()"/>
+
+    <xsl:template match="/">
+      <xsl:value-of select="$lang.title"/>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="title" select="$lang.title"/>
+	</xsl:call-template>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:apply-templates/>
+    </xsl:template>
+
+    <!-- Process the interface element -->
+    <xsl:template match="adr:interface">
+      <!-- Write out a heading -->
+      <xsl:text>&#xA;</xsl:text>	  
+      <xsl:text>  </xsl:text> <!-- indent = 2 -->
+      <xsl:value-of select="$lang.intfHead"/>
+      <xsl:value-of select="@name"/>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="4"/>	
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+      
+      <!-- Process the enum elements, if any -->
+      <xsl:if test="adr:enum">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="$lang.enumTitle"/>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="title" select="$lang.enumTitle"/>
+	  <xsl:with-param name="indent" select="4"/>
+	</xsl:call-template>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:enum"/>
+      </xsl:if>
+      
+      <!-- Process the type elements, if any -->
+      <xsl:if test="adr:type">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="$lang.structTitle"/>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="title" select="$lang.structTitle"/>
+	  <xsl:with-param name="indent" select="4"/>
+	</xsl:call-template>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:type"/>
+      </xsl:if>
+
+      <!-- Process the api elements, if any -->
+      <xsl:if test="adr:api">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="$lang.apiTitle"/>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="title" select="$lang.apiTitle"/>
+	  <xsl:with-param name="indent" select="4"/>
+	</xsl:call-template>
+	<xsl:apply-templates select="adr:api"/>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process the enum, enum value, enum fallback elements -->
+    <xsl:template match="adr:interface/adr:enum">
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>    </xsl:text> <!-- indent = 4 -->
+      <xsl:value-of select="$lang.enumLabel"/>
+      <xsl:value-of select="@name"/>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="4"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:call-template name="tenum"/>
+      <xsl:apply-templates select="adr:fallback"/>
+    </xsl:template>
+
+    <!-- Process all the enum value elements -->
+    <xsl:template name="tenum">
+      <xsl:param name="thenode" select="adr:value[1]"/>
+      <xsl:param name="initval" select="0"/>
+      <xsl:variable name="currvalue">
+	<xsl:choose>
+          <xsl:when test="$thenode/@value">
+            <xsl:value-of select="$thenode/@value"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$initval"/>
+          </xsl:otherwise>
+	</xsl:choose>           
+      </xsl:variable>
+
+      <xsl:text>      </xsl:text> <!-- indent = 6 -->
+      <xsl:value-of select="$thenode/@name"/>
+      <xsl:text> (</xsl:text>
+      <xsl:value-of select="$currvalue"/>
+      <xsl:text>)</xsl:text>
+      <xsl:apply-templates select="$thenode/adr:summary"/>
+      <xsl:apply-templates select="$thenode/adr:doc">
+	<xsl:with-param name="indent" select="8"/>
+      </xsl:apply-templates>
+      <xsl:if test="not($thenode/adr:summary)">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+
+      <xsl:if test="$thenode/following-sibling::adr:value[1]">
+	<xsl:call-template name="tenum">
+	  <xsl:with-param name="thenode" 
+	    select="$thenode/following-sibling::adr:value[1]"/>
+	  <xsl:with-param name="initval" select="$currvalue + 1"/>
+	</xsl:call-template>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process the enum fallback elements -->
+    <xsl:template match="adr:enum/adr:fallback">
+      <xsl:text>      </xsl:text> <!-- indent = 6 -->
+      <xsl:value-of select="$lang.fbLabel"/>
+      <xsl:text>(</xsl:text>
+      <xsl:value-of select="@name"/>
+      <xsl:text>)</xsl:text>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="8"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+    </xsl:template>
+    
+    <!-- Process the type (struct), type field, include elements -->
+    <xsl:template match="adr:interface/adr:type">
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>    </xsl:text> <!-- indent = 4 -->
+      <xsl:value-of select="$lang.structLabel"/>
+      <xsl:value-of select="@name"/>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="4"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:apply-templates select="adr:include"/>
+      <xsl:apply-templates select="adr:field"/>
+    </xsl:template>
+    
+    <!-- Process the include elements within a type definition -->
+    <xsl:template match="adr:type/adr:include">
+      <xsl:apply-templates select="//adr:type[@name = current()/@typeref]"
+	mode="include"/>
+    </xsl:template>
+    
+    <!-- Process the type field elements -->
+    <xsl:template match="adr:type/adr:field">
+      <xsl:text>      </xsl:text> <!-- indent = 6 -->
+      <xsl:value-of select="@name"/>
+      <xsl:text> (</xsl:text>
+      <xsl:call-template name="ttype"/>
+      <xsl:call-template name="topt"/>
+      <xsl:text>)</xsl:text>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="8"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+    </xsl:template>
+    
+    <!-- Process included type elements -->
+    <xsl:template match="adr:type" mode="include">
+      <xsl:apply-templates select="adr:field"/>
+    </xsl:template>
+    
+    <!-- Process the api, api property, api method, api event elements -->
+    <xsl:template match="adr:interface/adr:api">
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>    </xsl:text> <!-- indent = 4 -->
+      <xsl:value-of select="$lang.apiHead"/>
+      <xsl:value-of select="@name"/>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="6"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+
+      <!-- Process the version elements, if any -->
+      <xsl:apply-templates select="adr:version[position() = 1]"/>
+      
+      <!-- Save the "included" api, if any -->
+      <xsl:variable name="incApi" 
+	  select="//adr:api[@name = current()/adr:include/@typeref]"/>
+      
+      <!-- Write a properties header, if needed -->
+      <xsl:if test="adr:property | $incApi/adr:property">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="$lang.propHead"/>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="title" select="$lang.propHead"/>
+	  <xsl:with-param name="indent" select="4"/>
+	</xsl:call-template>
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+
+      <!-- Process the api properties, if any -->
+      <xsl:if test="adr:property">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="@name"/>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="$lang.propHead"/>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:property"/>
+      </xsl:if>
+
+      <!-- Process the included api properties, if any -->
+      <xsl:if test="$incApi/adr:property">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="@name"/>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="$lang.propHead"/>
+	<xsl:text> (</xsl:text>
+	<xsl:value-of select="$lang.incApiHead"/>
+	<xsl:value-of select="$lang.apiHead"/>
+	<xsl:value-of select="current()/adr:include/@typeref"/>
+	<xsl:text>)</xsl:text>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="$incApi/adr:property"/>
+      </xsl:if>
+
+      <!-- Write a methods header, if needed -->
+      <xsl:if test="adr:method | $incApi/adr:method">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="$lang.methHead"/>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="title" select="$lang.methHead"/>
+	  <xsl:with-param name="indent" select="4"/>
+	</xsl:call-template>
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+
+      <!-- Process the api methods, if any -->
+      <xsl:if test="adr:method">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="@name"/>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="$lang.methHead"/>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:method"/>
+      </xsl:if>
+
+      <!-- Process the included api methods, if any -->
+      <xsl:if test="$incApi/adr:method">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="@name"/>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="$lang.methHead"/>
+	<xsl:text> (</xsl:text>
+	<xsl:value-of select="$lang.incApiHead"/>
+	<xsl:value-of select="$lang.apiHead"/>
+	<xsl:value-of select="current()/adr:include/@typeref"/>
+	<xsl:text>)</xsl:text>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="$incApi/adr:method"/>
+      </xsl:if>
+
+      <!-- Write an events header, if needed -->
+      <xsl:if test="adr:event | $incApi/adr:event">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="$lang.evHead"/>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="title" select="$lang.evHead"/>
+	  <xsl:with-param name="indent" select="4"/>
+	</xsl:call-template>
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+
+      <!-- Process the api events, if any -->
+      <xsl:if test="adr:event">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="@name"/>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="$lang.evHead"/>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:event"/>
+      </xsl:if>
+
+      <!-- Process the included api events, if any -->
+      <xsl:if test="$incApi/adr:event">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>    </xsl:text> <!-- indent = 4 -->
+	<xsl:value-of select="@name"/>
+	<xsl:text> </xsl:text>
+	<xsl:value-of select="$lang.evHead"/>
+	<xsl:text> (</xsl:text>
+	<xsl:value-of select="$lang.incApiHead"/>
+	<xsl:value-of select="$lang.apiHead"/>
+	<xsl:value-of select="current()/adr:include/@typeref"/>
+	<xsl:text>)</xsl:text>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="$incApi/adr:event"/>
+      </xsl:if>
+
+    </xsl:template> <!-- end api property, api method, api event elements -->
+
+    <!-- Process api version elements -->
+    <xsl:template match="adr:api/adr:version">
+      <xsl:text>      </xsl:text> <!-- indent = 6 -->
+      <xsl:value-of select="$lang.verLabel"/>
+      <xsl:for-each select="parent::node()/adr:version">
+	<xsl:value-of select="@stability"/>
+	<xsl:text>(</xsl:text>
+	<xsl:value-of select="@major"/>
+	<xsl:text>.</xsl:text>
+	<xsl:value-of select="@minor"/>
+	<xsl:text>)</xsl:text>
+	<xsl:if test="position() != last()">, </xsl:if>
+      </xsl:for-each>
+      <xsl:text>&#xA;</xsl:text>
+    </xsl:template>
+
+    <!-- Process the property, property error elements -->
+    <xsl:template match="adr:property">
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>      </xsl:text> <!-- indent = 6 -->
+      <xsl:value-of select="$lang.propLabel"/>
+      <xsl:value-of select="@name"/>
+      <xsl:text> (</xsl:text>
+      <xsl:call-template name="ttype"/>
+      <xsl:text>, </xsl:text>
+      <xsl:call-template name="taccess"/>
+      <xsl:call-template name="topt"/>
+      <xsl:text>)</xsl:text>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="6"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+      <xsl:apply-templates select="adr:error"/>
+    </xsl:template>
+
+    <!-- Process the property error elements -->
+    <xsl:template match="adr:property/adr:error">
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>        </xsl:text> <!-- indent = 8 -->
+      <xsl:choose>
+	<xsl:when test="@for='ro' or parent::node()/@access='ro'">
+	  <xsl:value-of select="$lang.roLabel"/>
+	</xsl:when>
+	<xsl:when test="@for='wo' or parent::node()/@access='wo'">
+	  <xsl:value-of select="$lang.woLabel"/>
+	</xsl:when>
+	<xsl:when test="@for='rw' or parent::node()/@access='rw'">
+	  <xsl:value-of select="$lang.rwLabel"/>
+	</xsl:when>
+      </xsl:choose>
+      <xsl:value-of select="$lang.errLabel"/>
+      <xsl:text> </xsl:text>
+      <xsl:call-template name="ttype"/>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="10"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+    </xsl:template>
+    
+    <!-- Process the method, argument, result, method error elements -->
+    <xsl:template match="adr:api/adr:method">
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>      </xsl:text> <!-- indent = 6 -->
+      <xsl:value-of select="$lang.methLabel"/>
+      <xsl:value-of select="@name"/>
+      <xsl:text>(</xsl:text>
+      <xsl:for-each select="adr:argument">
+	<xsl:value-of select="@name"/>
+	<xsl:if test="position() != last()">, </xsl:if>
+      </xsl:for-each>
+      <xsl:text>)</xsl:text>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="6"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+      <xsl:if test="count(adr:argument) > 0">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>        </xsl:text> <!-- indent = 8 -->
+	<xsl:value-of select="$lang.argLabel"/>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:argument"/>
+      </xsl:if>
+      <xsl:if test="count(adr:result) > 0">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>        </xsl:text> <!-- indent = 8 -->
+	<xsl:value-of select="$lang.resLabel"/>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:result"/>
+      </xsl:if>
+      <xsl:if test="count(adr:error) > 0">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:text>        </xsl:text> <!-- indent = 8 -->
+	<xsl:value-of select="$lang.errLabel"/>
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:apply-templates select="adr:error"/>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process the method argument elements -->
+    <xsl:template match="adr:method/adr:argument">
+      <xsl:text>        </xsl:text> <!-- indent = 8 -->
+      <xsl:value-of select="@name"/>
+      <xsl:text> (</xsl:text>
+      <xsl:call-template name="ttype"/>
+      <xsl:call-template name="topt"/>
+      <xsl:text>)</xsl:text>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="10"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+    </xsl:template>
+    
+    <!-- Process the method result elements -->
+    <xsl:template match="adr:method/adr:result">
+      <xsl:text>        </xsl:text> <!-- indent = 8 -->
+      <xsl:call-template name="ttype"/>
+      <xsl:if test="@optional='true' or @optional='1'">
+	<xsl:text> (</xsl:text>
+	<xsl:value-of select="$lang.optLabel"/>
+	<xsl:text>)</xsl:text>
+      </xsl:if>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="10"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+    </xsl:template>
+    
+    <!-- Process the method error elements -->
+    <xsl:template match="adr:method/adr:error">
+      <xsl:text>        </xsl:text> <!-- indent = 8 -->
+      <xsl:call-template name="ttype"/>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="10"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process the event elements -->
+    <xsl:template match="adr:api/adr:event">
+      <xsl:text>&#xA;</xsl:text> 
+      <xsl:text>      </xsl:text> <!-- indent = 6 -->
+      <xsl:value-of select="$lang.evLabel"/>
+      <xsl:value-of select="@name"/>
+      <xsl:apply-templates select="adr:summary"/>
+      <xsl:apply-templates select="adr:doc">
+	<xsl:with-param name="indent" select="8"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[1][self::adr:summary|self::adr:doc])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:text>        </xsl:text> <!-- indent = 8 -->
+      <xsl:value-of select="$lang.typeLabel"/>
+      <xsl:call-template name="ttype"/>
+      <xsl:text>&#xA;</xsl:text>
+    </xsl:template>
+
+    <!-- Named Templates -->
+    <!-- Process type definition for structs fields, props, methods, events -->
+    <xsl:template name="ttype">
+      <xsl:choose>
+	<xsl:when test="@type">
+	  <xsl:value-of select="@type"/>
+	</xsl:when>
+	<xsl:when test="@typeref">
+	  <xsl:apply-templates 
+	     select="(//adr:type|//adr:enum)[@name = current()/@typeref]"
+	     mode="refclass"/>
+	  <xsl:value-of select="@typeref"/>
+	</xsl:when>
+	<xsl:when test="adr:list/@type">
+	  <xsl:value-of select="adr:list/@type"/><xsl:text>[]</xsl:text>
+	</xsl:when>
+	<xsl:when test="adr:list/@typeref">
+	  <xsl:apply-templates select="
+	     (//adr:type|//adr:enum)[@name = current()/adr:list/@typeref]"
+	     mode="refclass"/>
+	  <xsl:value-of select="adr:list/@typeref"/>
+	  <xsl:text>[]</xsl:text>
+	</xsl:when>
+	<xsl:otherwise>
+	  <xsl:value-of select="$lang.voidLabel"/>
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+    <!-- Process optional attribute for struct fields, methods -->
+    <xsl:template name="topt">
+      <xsl:if test="@optional='true' or @optional='1'">
+	<xsl:text>, </xsl:text>
+	<xsl:value-of select="$lang.optLabel"/>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process access attribute for properties -->
+    <xsl:template name="taccess">
+      <xsl:choose>
+	<xsl:when test="@access='ro'">
+	  <xsl:value-of select="$lang.roProp"/>
+	</xsl:when>
+	<xsl:when test="@access='wo'">
+	  <xsl:value-of select="$lang.woProp"/>
+	</xsl:when>
+	<xsl:otherwise> <!-- access=rw -->
+	  <xsl:value-of select="$lang.rwProp"/>
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+    <!-- Output formatting -->
+    <xsl:template name="tunderline">
+      <xsl:param name="title" select="''"/>
+      <xsl:param name="indent" select="0"/>
+      <xsl:param name="len" select="string-length($title)"/>
+      <xsl:if test="string-length($title) > 0">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:value-of select="substring($indentstr, 1, $indent)"/>
+      </xsl:if>
+      <xsl:if test="$len > 0">
+	<xsl:text>-</xsl:text>
+	<xsl:call-template name="tunderline">
+	  <xsl:with-param name="len" select="$len - 1"/>
+	</xsl:call-template>
+      </xsl:if>
+    </xsl:template>
+      
+    <!-- Templates for type specification -->
+    <xsl:template match="adr:enum" mode="refclass">
+      <xsl:value-of select="$lang.enumLabel"/>
+    </xsl:template>
+
+    <xsl:template match="adr:type" mode="refclass">
+      <xsl:value-of select="$lang.structLabel"/>
+    </xsl:template> 
+
+    <!-- Process the documentation elements - adr:summary, adr:doc -->
+    <!-- Process the documentation summary elements -->
+    <xsl:template match="adr:summary">
+      <xsl:text> -- </xsl:text>
+      <xsl:apply-templates/>
+      <xsl:text>&#xA;</xsl:text>
+    </xsl:template>
+
+    <!-- Process the summary text nodes -->
+    <xsl:template match="adr:summary//text()">
+      <xsl:value-of select="normalize-space(.)"/>
+    </xsl:template>
+
+    <!-- Process the (inline) code doc elements -->
+    <xsl:template match="adr:summary//adr:code|adr:doc//adr:code">
+      <xsl:if test="preceding-sibling::node()">
+	<xsl:text> </xsl:text>
+      </xsl:if>
+      <xsl:apply-templates/>
+      <xsl:if test="following-sibling::node()">
+	<xsl:text> </xsl:text>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process the (inline) strong doc elements -->
+    <xsl:template match="adr:summary//adr:strong|adr:doc//adr:strong">
+      <xsl:if test="preceding-sibling::node()">
+	<xsl:text> </xsl:text>
+      </xsl:if>
+      <xsl:apply-templates/>
+      <xsl:if test="following-sibling::node()">
+	<xsl:text> </xsl:text>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process the (inline) link doc elements -->
+    <xsl:template match="adr:summary//adr:link|adr:doc//adr:link">
+      <xsl:text> (</xsl:text>
+      <xsl:value-of select="@url"/>
+      <xsl:text>) </xsl:text>
+      <xsl:apply-templates/>
+      <xsl:text> </xsl:text>
+    </xsl:template>
+
+    <!-- Process the (inline) br doc elements -->
+    <xsl:template match="adr:summary//adr:br|adr:doc//adr:br">
+      <xsl:text>&#xA;</xsl:text>
+    </xsl:template>
+
+    <!-- Process the detail documentation (doc) elements -->
+    <xsl:template match="adr:doc">
+      <xsl:param name="indent" select="0"/>
+      <xsl:if test="not(child::*[1][self::adr:para])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+      <xsl:apply-templates select="text()[normalize-space(.) != '']|*">
+	<xsl:with-param name="indent" select="$indent"/>
+      </xsl:apply-templates>
+      <xsl:if test="not(child::*[last()][self::adr:para])">
+	<xsl:text>&#xA;</xsl:text>
+      </xsl:if>
+    </xsl:template>
+
+    <!-- Process the doc text nodes -->
+    <xsl:template match="adr:doc//text()">
+      <xsl:param name="indent" select="0"/>
+      <xsl:if test="$indent > 0">
+	<!-- If a text node is the first element or if a text node occurs right 
+	     after a br element, indent the text on output -->
+	<xsl:if test=
+	  "(not(preceding-sibling::*))or preceding-sibling::*[1][self::adr:br]">
+	  <xsl:value-of select="substring($indentstr, 1, $indent)"/>
+	</xsl:if>
+      </xsl:if>
+      <xsl:value-of select="normalize-space(.)"/>
+    </xsl:template>
+
+    <!-- Process the (block) heading doc elements -->
+    <xsl:template match="adr:doc//adr:heading">
+      <xsl:param name="indent" select="0"/>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:if test="$indent > 0">
+	<xsl:value-of select="substring($indentstr, 1, $indent)"/>
+      </xsl:if>
+      <xsl:variable name="heading">
+	<xsl:value-of select="normalize-space(.)"/>
+      </xsl:variable>
+      <xsl:value-of select="$heading"/>
+      <xsl:call-template name="tunderline">
+	<xsl:with-param name="indent" select="$indent"/>
+	<xsl:with-param name="title" select="$heading"/>
+      </xsl:call-template>
+      <xsl:text>&#xA;</xsl:text>
+    </xsl:template>
+
+    <!-- Process the (block) para doc elements -->
+    <xsl:template match="adr:doc//adr:para">
+      <xsl:param name="indent" select="0"/>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:apply-templates select="text()[normalize-space(.)]|*">
+	<xsl:with-param name="indent" select="$indent"/>
+      </xsl:apply-templates>
+      <xsl:text>&#xA;</xsl:text>
+    </xsl:template>
+
+    <!-- Process the (block) list doc elements -->
+    <xsl:template match="adr:doc//adr:list">
+      <xsl:param name="indent" select="0"/>
+      <xsl:apply-templates select="adr:item">
+	<xsl:with-param name="indent" select="$indent + 2"/>
+      </xsl:apply-templates>
+    </xsl:template>
+
+    <!-- Process the (block) list item doc elements -->
+    <xsl:template match="adr:list/adr:item">
+      <xsl:param name="indent" select="0"/>
+      <xsl:if test="$indent > 0">
+	<xsl:text>&#xA;</xsl:text>
+	<xsl:value-of select="substring($indentstr, 1, $indent)"/>
+      </xsl:if>
+      <xsl:choose>
+	<xsl:when test="parent::node()[@type ='ordered']">
+	  <xsl:number/><xsl:text>. </xsl:text>
+	  <xsl:apply-templates select="text()[normalize-space(.)]|*"/>
+	</xsl:when>
+	<xsl:otherwise>
+	  <xsl:text>* </xsl:text>
+	  <xsl:apply-templates select="text()[normalize-space(.)]|*"/>
+	</xsl:otherwise>
+      </xsl:choose>
+    </xsl:template>
+
+    <!-- Process the (block) example doc elements -->
+    <xsl:template match="adr:doc//adr:example">
+      <xsl:param name="indent" select="0"/>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:if test="$indent > 0">
+	<xsl:value-of select="substring($indentstr, 1, $indent)"/>
+      </xsl:if>
+      <xsl:value-of select="@caption"/>
+      <xsl:text>&#xA;</xsl:text>
+      <xsl:value-of select="self::node()"/>
+    </xsl:template>
+
+</xsl:stylesheet>
--- a/usr/src/java/adr/org/opensolaris/os/adr/adrgen/CGenerator.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/adrgen/CGenerator.java	Fri May 06 14:55:38 2011 -0400
@@ -277,8 +277,8 @@
 			prop.getName(),
 			toStabilityStr(prop.getStability()),
 			getTargetName(prop.getType()),
-			toErrorPtr(prop.getReadError()),
-			toErrorPtr(prop.getWriteError()),
+			toErrorPtr(prop.getReadErrorType()),
+			toErrorPtr(prop.getWriteErrorType()),
 			toBoolean(prop.isOptional()),
 			toBoolean(prop.isReadable()),
 			toBoolean(prop.isWritable()));
@@ -361,9 +361,9 @@
 			method.getName(),
 			toStabilityStr(method.getStability()),
 			method.getArguments().size(),
-			getTargetName(method.getType()),
-			toErrorPtr(method.getError()),
-			toBoolean(method.isOptional()), paramname);
+			getTargetName(method.getResult().getType()),
+			toErrorPtr(method.getErrorType()),
+			toBoolean(method.getResult().isOptional()), paramname);
 		    o_impl.format("};\n\n");
 		    invokers.add(mfunc);
 		}
@@ -503,8 +503,8 @@
 	    o_stubs.format("%s(rad_instance_t *inst, adr_method_t *meth,\n",
 		invoker);
 	    o_stubs.format(
-		"    data_t **ret, data_t **args, int count, data_t **error)\n"
-		);
+		"    data_t **ret, data_t **args, int count, " +
+		"data_t **error)\n");
 	    o_stubs.format("{\n");
 	    o_stubs.format(
 		"\t(void) fprintf(stderr, \"NOT IMPLEMENTED: %s\\n\");\n",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/java/adr/org/opensolaris/os/adr/adrgen/DocGenerator.java	Fri May 06 14:55:38 2011 -0400
@@ -0,0 +1,67 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ */
+
+package org.opensolaris.os.adr.adrgen;
+
+import org.opensolaris.os.adr.*;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import org.w3c.dom.Document;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.stream.StreamResult;
+
+public class DocGenerator {
+
+    enum Format { NONE, TEXT, DOCBOOK };
+    private static final String RMFMT = "ADRrmdoc.xsl";
+    private static final String DBFMT = "ADRdocbook.xsl";
+    private static final String TXTFMT = "ADRtext.xsl";
+
+    static void generate(ADRGen parser, Format doc_fmt)
+	throws FileNotFoundException, TransformerException,
+	TransformerConfigurationException {
+	StreamResult output = new StreamResult(System.out);
+	String resource;
+	if (doc_fmt == Format.DOCBOOK)
+	    resource = DBFMT;
+	else if (doc_fmt == Format.TEXT)
+	    resource = TXTFMT;
+	else
+	    resource = RMFMT;
+	InputStream is = DocGenerator.class.getResourceAsStream(resource);
+	StreamSource stylesource = new StreamSource(is);
+
+	TransformerFactory tFactory = TransformerFactory.newInstance();
+	Transformer transformer = tFactory.newTransformer(stylesource);
+	DOMSource source = new DOMSource(parser.doc_);
+	transformer.transform(source, output);
+    }
+}
--- a/usr/src/java/adr/org/opensolaris/os/adr/adrgen/JGenerator.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/adr/org/opensolaris/os/adr/adrgen/JGenerator.java	Fri May 06 14:55:38 2011 -0400
@@ -411,8 +411,8 @@
 	     * First, define attributes
 	     */
 	    for (Property prop : api.getAllProps().values()) {
-		String readEx = toThrows(prop.getReadError(), pedant);
-		String writeEx = toThrows(prop.getWriteError(), pedant);
+		String readEx = toThrows(prop.getReadErrorType(), pedant);
+		String writeEx = toThrows(prop.getWriteErrorType(), pedant);
 
 		if (prop.isReadable()) {
 		    out.format("    @%s(%s.%s)\n", STAB_ANN, STAB_ENUM,
@@ -438,13 +438,13 @@
 	    for (Method method : api.getAllMethods().values()) {
 		out.format("    @%s(%s.%s)\n", STAB_ANN, STAB_ENUM,
 		    method.getStability());
-		out.format("    %s %s(", getTypedName(method),
+		out.format("    %s %s(", getTypedName(method.getResult()),
 		    method.getName());
 		int count = method.getArguments().size();
 		for (Argument arg : method.getArguments())
 		    out.format(--count == 0 ? "%s %s" : "%s %s, ",
 			getTypedName(arg), arg.getName());
-		out.format(")%s;\n\n", toThrows(method.getError(), pedant));
+		out.format(")%s;\n\n", toThrows(method.getErrorType(), pedant));
 	    }
 
 	    out.format("}\n");
--- a/usr/src/java/build-common.xml	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/build-common.xml	Fri May 06 14:55:38 2011 -0400
@@ -145,6 +145,7 @@
 				<patternset id="pattern.resources">
 					<!-- <include name="org/**/*.rng" /> -->
 					<include name="org/**/*.xsd" />
+					<include name="org/**/*.xsl" />
 					<include name="org/**/*.properties" />
 					<include name="org/**/panel.policy" />
 					<include name="org/**/help/**" />
--- a/usr/src/java/rad/org/opensolaris/os/rad/ADRXDR.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/rad/org/opensolaris/os/rad/ADRXDR.java	Fri May 06 14:55:38 2011 -0400
@@ -170,7 +170,8 @@
 	    break;
 	case DT_ENUM:
 	    String ename = typestr.getString();
-	    String fallback = typestr.getBoolean() ? typestr.getString() : null;
+	    Type.EnumValue fallback = typestr.getBoolean() ?
+		new Type.EnumValue(typestr.getString(), 0) : null;
 	    int nvalues = typestr.getInteger();
 	    List<Type.EnumValue> values =
 		new ArrayList<Type.EnumValue>(nvalues);
--- a/usr/src/java/rad/org/opensolaris/os/rad/Client.java	Thu May 05 13:16:34 2011 -0700
+++ b/usr/src/java/rad/org/opensolaris/os/rad/Client.java	Fri May 06 14:55:38 2011 -0400
@@ -209,7 +209,8 @@
 	Response r = framer_.syncRequest(SETATTR, descop);
 
 	if (!r.isSuccess())
-	    throw toException(r, inst.getName().toString(), p.getWriteError());
+	    throw toException(r, inst.getName().toString(),
+		p.getWriteErrorType());
     }
 
     public Object getattr(Instance inst, String aname)
@@ -239,7 +240,8 @@
 		    "result: ODE error");
 	    }
 	} else {
-	    throw toException(r, inst.getName().toString(), p.getReadError());
+	    throw toException(r, inst.getName().toString(),
+		p.getReadErrorType());
 	}
     }
 
@@ -292,7 +294,7 @@
 		    "result: ODE error");
 	    }
 	} else {
-	    throw toException(r, inst.getName().toString(), m.getError());
+	    throw toException(r, inst.getName().toString(), m.getErrorType());
 	}
     }
 
@@ -342,9 +344,12 @@
 	    Type type = adrxdr_.readRef(descresp, types, false);
 	    Type readErrorType = adrxdr_.readRef(descresp, types, true);
 	    Type writeErrorType = adrxdr_.readRef(descresp, types, true);
+	    ADRError rerr = readErrorType != null ?
+		new ADRError(readErrorType) : null;
+	    ADRError werr = writeErrorType != null ?
+		new ADRError(writeErrorType) : null;
 	    props.put(attname, new Property(attname, stability, type,
-		optional, readable, writable, readErrorType,
-		writeErrorType));
+		optional, readable, writable, rerr, werr));
 	}
 
 	/*
@@ -357,7 +362,9 @@
 	    Stability stability = ADRXDR.readStability(descresp);
 	    boolean optional = descresp.getBoolean();
 	    Type type = adrxdr_.readRef(descresp, types, false);
-	    Type errortype = adrxdr_.readRef(descresp, types, true);
+	    Result result = new Result(type, optional);
+	    Type terr = adrxdr_.readRef(descresp, types, true);
+	    ADRError errortype = terr != null ? new ADRError(terr) : null;
 	    int acount = descresp.getInteger();
 	    List<Argument> args = new ArrayList<Argument>(acount);
 	    for (int j = 0; j < acount; j++) {
@@ -366,7 +373,7 @@
 		Type ptype = adrxdr_.readRef(descresp, types, false);
 		args.add(new Argument(pname, ptype, poptional));
 	    }
-	    meths.put(mname, new Method(mname, stability, type, optional,
+	    meths.put(mname, new Method(mname, stability, result,
 		args, errortype));
 	}