You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Elena Litani <el...@ca.ibm.com> on 2002/08/22 21:41:37 UTC

PSVI: How to access Annotations

Following requests from the Xerces community, here is a proposal on how
to expose the XML Schema annotation component.

This proposal does not specify what should happen with in-scope
namespace declarations (that were declared on an annotation parent
element).

There are 2 possible solutions:
1. Require that in-scope namespace declarations are *serialized*:
  - toDOM and getAnnotationString: add namespace declarations on
<annotation> element
  - toDocumentHandler: sent corresponding start/endPrefixMapping events

2. Add NamespaceResolver getNamespaceResolver() method on XSAnnotation.
NamespaceResolver is a read-only interface that represents in-scope
declarations:
 - public String getURI(String prefix): Look up a prefix and get the
currently-mapped Namespace URI
 - public String getPrefix(String uri): Look up a namespace URI and get
one of the mapped prefix
 - public int getDeclaredPrefixCount(): Return a count of all prefixes
currently declared, including the default prefix if bound.
 - public String getDeclaredPrefixAt(int index);

interface XSAnnotation extends XSObject {
  
    /**
     * Write contents of the annotation to the specified DOM object,
     * 
     * @param target - a target pointer to the annotation target object,
     * i.e.  org.w3c.dom.Document, org.w3c.dom.Node.
     *     
     * @exception Exception NOT_SUPPORTED_ERR: Raised if  an
     * implementation  does not provide
     *                      an implementation for this method
     * @exception Exception WRONG _TYPE Raised if  an implementation
     * cannot write annotation to the specified target.
     */
     public void toDOM(Object target) throws Exception;

    /**
     * Write contents of the annotation to the specified document
     * handler, i.e. org.xml.sax.ContentHandler, xni.XMLDocumentHandler
     * 
     * @param documentHandler  The document handler.
     * 
     * @exception Exception NOT_SUPPORTED_ERR: Raised if  an
     * implementation  does not provide
     *                      an implementation for this method
     * @exception Exception WRONG _TYPE Raised if  an implementation
     * cannot write annotation to the specified target.
     */
     public void toDocumentHandler (Object documentHandler) throws
                  Exception;

     /**
     * A text representation of annotation.
     */
    public String getAnnotationString();
  
};

Comments are welcome!
-- 
Elena Litani / IBM Toronto

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: PSVI: How to access Annotations

Posted by Manish Balsara <mb...@yahoo.com>.
Elena

The interfaces defined below would work for us,
provided there are additional methods to save and
retrieve parsed annotations. This would allow us to
parse the Annotation the first time it is encountered
and attach it with XSAnnotation. For us option 2 does
not provide much benefit since Annotations would be
contained in the parent XSObject.

Also, are there any plans to add support for parsing
extensible elements/attributes in schema? If there
are, would it be better to look at using a similar
mechanism for parsing Annotations and extensible
elements/attributes?

manish


--- Elena Litani <el...@ca.ibm.com> wrote:
> Following requests from the Xerces community, here
> is a proposal on how
> to expose the XML Schema annotation component.
> 
> This proposal does not specify what should happen
> with in-scope
> namespace declarations (that were declared on an
> annotation parent
> element).
> 
> There are 2 possible solutions:
> 1. Require that in-scope namespace declarations are
> *serialized*:
>   - toDOM and getAnnotationString: add namespace
> declarations on
> <annotation> element
>   - toDocumentHandler: sent corresponding
> start/endPrefixMapping events
> 
> 2. Add NamespaceResolver getNamespaceResolver()
> method on XSAnnotation.
> NamespaceResolver is a read-only interface that
> represents in-scope
> declarations:
>  - public String getURI(String prefix): Look up a
> prefix and get the
> currently-mapped Namespace URI
>  - public String getPrefix(String uri): Look up a
> namespace URI and get
> one of the mapped prefix
>  - public int getDeclaredPrefixCount(): Return a
> count of all prefixes
> currently declared, including the default prefix if
> bound.
>  - public String getDeclaredPrefixAt(int index);
> 
> interface XSAnnotation extends XSObject {
>   
>     /**
>      * Write contents of the annotation to the
> specified DOM object,
>      * 
>      * @param target - a target pointer to the
> annotation target object,
>      * i.e.  org.w3c.dom.Document, org.w3c.dom.Node.
>      *     
>      * @exception Exception NOT_SUPPORTED_ERR:
> Raised if  an
>      * implementation  does not provide
>      *                      an implementation for
> this method
>      * @exception Exception WRONG _TYPE Raised if 
> an implementation
>      * cannot write annotation to the specified
> target.
>      */
>      public void toDOM(Object target) throws
> Exception;
> 
>     /**
>      * Write contents of the annotation to the
> specified document
>      * handler, i.e. org.xml.sax.ContentHandler,
> xni.XMLDocumentHandler
>      * 
>      * @param documentHandler  The document handler.
>      * 
>      * @exception Exception NOT_SUPPORTED_ERR:
> Raised if  an
>      * implementation  does not provide
>      *                      an implementation for
> this method
>      * @exception Exception WRONG _TYPE Raised if 
> an implementation
>      * cannot write annotation to the specified
> target.
>      */
>      public void toDocumentHandler (Object
> documentHandler) throws
>                   Exception;
> 
>      /**
>      * A text representation of annotation.
>      */
>     public String getAnnotationString();
>   
> };
> 
> Comments are welcome!
> -- 
> Elena Litani / IBM Toronto
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xerces-j-dev-help@xml.apache.org
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org