Your example is still dealing with the interpretation of a prefix in an 
existing document, and I don't have an existing document.  I am in control of 
which namespaces and which prefixes would be used.

HOWEVER, your last statement hits the nail on the head and explains everything. 
 Indeed, I have schema split across multiple documents, where a given prefix 
could be used for multiple namespaces and any namespace could have multiple 
prefixes.  I realized that this situation could occur in instance documents, 
without once thinking that the same would be true for a schema composed from 
multiple files.  Of course, the sample schema I created have unique prefixes!

Sorry for being so dense, and thanks for the replies.

Mark

On Oct 22, 2010, at 2:24 PM, Michael Glavassevich wrote:

> I think an example will help to illustrate why such a method makes no sense 
> in the API. Consider the following document:
> 
> <a:root xmlns:a="http://a"; xmlns:b="http://b";
>        xmlns:y="http://y"; xmlns:z="http://z";>
> <a:a xmlns:a="http://www.abc.com"; xmlns:x="http://www.xyz.com";>
>  <a:a xmlns:a="http://www.xyz.com"; xmlns:x="http://www.abc.com"/>
> </a:a>
> <y:a xmlns:b="http://www.abc.com"; xmlns:y="http://www.xyz.com";>
>  <y:a xmlns:b="http://www.xyz.com"; xmlns:y="http://www.abc.com"/>
> </y:a>
> </a:root>
> 
> What is the prefix for "http://www.abc.com";? Without also considering the 
> context you can't give a sensible answer. An XSModel may be composed of 
> multiple schema documents which could also have different prefix mappings in 
> each of them for the same namespaces.
> 
> Thanks.
> 
> On Fri, 22 Oct 2010, Mark Brucks wrote:
> 
>> Thanks for the responses.
>> Some clarification about my problem.  I have the schema, but no instance
>> documents, and hence no worries about the fluid nature of prefixes between
>> schema and instance documents.  My current task is to generate a "starter"
>> document from the schema.  What I would like to do is use the prefix values
>> from the schema in my instance document, under the assumption that the
>> person that wrote the schema found the prefix to be a good mnemonic, and
>> hence it would serve the same purpose in the instance document.  If I had
>> the prefix, it appears that I could then use
>> Element elem = CoreDocumentImpl.createElementNS(namespace, name);
>> elem.setPrefix(prefix);
>> to create the element in the given namespace and set the prefix to be
>> associated with that namespace (for that element). 
>> Doing this, I hope to generate an instance document that has
>> <s1:elementOne xmlns:s2="http://www.foo.com/SchemaTwo"; ...>
>> <s2:elementTwo ... />
>> instead of having elementTwo defined with
>> <elementTwo  xmlns="http://www.foo.com/SchemaTwo"; ... />
>> From what Michael says, it appears I can't get the prefix information from
>> XSModel.  From his phrase "not sure what it would mean to return such a
>> list", it seems I am missing something fundamental about why this wouldn't
>> be considered useful information.  The list would simply be a default
>> association of prefix with namespace.  It would be useful for my purpose,
>> but useless for processing any existing document.  Is there some reason that
>> what I want to do is a bad idea?
>> Thanks - Mark
>> On Oct 21, 2010, at 12:30 PM, Michael Glavassevich wrote:
>> 
>>      Hi Mark,
>> 
>>      Mark Brucks <bru...@charter.net> wrote on 10/21/2010 03:17:47
>>      PM:
>> 
>>      > Here is the beginning of my schema file:
>>      >
>>      > <xs:schema targetNamespace="http://www.foo.com/SchemaOne";
>>      >            xmlns:s1="http://www.foo.com/SchemaOne";
>>      >            xmlns:s2="http://www.foo.com/SchemaTwo";
>>      >            xmlns:s3="http://www.foo.com/SchemaThree";
>>      >            ...>
>>      >
>>      > Using the XML Schema API, I parse the schema and have access
>>      to the
>>      > resulting XSModel instance.  Using the method
>>      getNamespaceItems() I
>>      > can get a list of XSNamespaceItem and using the
>>      getSchemaNamespace()
>>      > method I can get all the namespaces.
>> 
>>      You're getting the list of all the target namespaces for the
>>      schema components in the XSModel. This has nothing to do with
>>      the namespace declarations which may have been in the schema
>>      documents.
>> 
>>      > How do I get the associated prefix for each prefix?
>> 
>>      You can't and not sure what it would mean to return such a list.
>>      The XSModel is a schema component view. There is no way to
>>      access the schema documents which composed it.
>> 
>>      > Thanks - Mark
>> 
>>      Thanks.
>> 
>>      Michael Glavassevich
>>      XML Parser Development
>>      IBM Toronto Lab
>>      E-mail: mrgla...@ca.ibm.com
>>      E-mail: mrgla...@apache.org
>> 
> 
> ---------------------------
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrgla...@ca.ibm.com
> E-mail: mrgla...@apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
> For additional commands, e-mail: j-users-h...@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org
For additional commands, e-mail: j-users-h...@xerces.apache.org

Reply via email to