Hi Geert,

Your suggestion works for me. The schema works, and I manually created
xml data and it get validated.  I get the results I want. Thanks a lot
for your help.

Helen

On Thu, Jul 14, 2011 at 3:18 AM, Geert Josten <[email protected]> wrote:
> Hi Helen,
>
> If you want the phone element to be the proxy namespace, then put it in that 
> schema file, and use <xs:element ref="pxtns:phone" /> from the contact 
> schema. Generating samples out of a schema can be difficult. Add the elements 
> you were expecting manually and try validating the result. It should validate.
>
> You will need a different schema file for each target namespace, but 
> otherwise I see no reason why it shouldn't be possible to base author and 
> editor on same common person type, while they have different namespaces 
> themselves.
>
> HTH,
> Geert
>
> -----Oorspronkelijk bericht-----
> Van: [email protected] 
> [mailto:[email protected]] Namens helen chen
> Verzonden: woensdag 13 juli 2011 22:34
> Aan: General MarkLogic Developer Discussion
> Onderwerp: Re: [MarkLogic Dev General] question about organizing schema
>
> Hi Geert and Joe,
>
> Thanks for the suggestion. I read the article, and I can make
> chameleon schema work for me.
>
> One question here is: it looks like including chameleon schema will
> make the element to use the parent schema's target namespace. It works
> good if I want them to be in the same namespace.
>
> If I want to do the following:
> I have a chameleon schema which defines phone structure called common.xsd
> then in my document schema, I want to include  common.xsd to my
> account.xsd, and I want to have phone to be in a different namespace
> other than the account target namespace. I 'm trying to think if I can
> make author in one namespace other than target namespace, and make
> editor to be in another namespace other than target namespace. (Does
> it make sense? Am I too crazy here?)
>
> following this idea, I tried proxy schema:
>
> my chameleon common schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> elementFormDefault="qualified" attributeFormDefault="qualified">
>        <xs:annotation>
>                <xs:documentation>This scheme defines common shared data object
> types.</xs:documentation>
>        </xs:annotation>
>        <xs:complexType name="PhoneNumber">
>                <xs:sequence>
>                        <xs:element name="countryCode" type="xs:string" 
> minOccurs="0" maxOccurs="1"/>
>                        <xs:element name="areaCode" type="xs:string" 
> minOccurs="0" maxOccurs="1"/>
>                        <xs:element name="exchange" type="xs:string" 
> minOccurs="0" maxOccurs="1"/>
>                        <xs:element name="number" type="xs:string" 
> minOccurs="0" maxOccurs="1"/>
>                        <xs:element name="extension" type="xs:string" 
> minOccurs="0" maxOccurs="1"/>
>                </xs:sequence>
>        </xs:complexType>
> </xs:schema>
>
>
> my proxy schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> xmlns:pxtns="http://www.aa.com/datamodel/proxy-common";
> targetNamespace="http://www.aa.com/datamodel/proxy-common";
> elementFormDefault="qualified" attributeFormDefault="qualified">
> <xs:annotation>
> <xs:documentation>This is a proxy schema to make chameleon common.xsd
> to have different namespace</xs:documentation>
> </xs:annotation>
> <xs:include schemaLocation="common_chameleon.xsd"/>
> </xs:schema>
>
> then my contact schema which import proxy schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> xmlns:tns="http://www.aa.com/datamodel/account";
> xmlns:pxtns="http://www.aa.com/datamodel/proxy-common";
> targetNamespace="http://www.aa.com/datamodel/account";
> elementFormDefault="qualified" attributeFormDefault="qualified">
>        <xs:annotation>
>                <xs:documentation>This schema defines data object types used 
> for
> interfaces</xs:documentation>
>        </xs:annotation>
>        <xs:import namespace="http://www.aa.com/datamodel/proxy-common";
> schemaLocation="common_proxy.xsd"/>
>        <xs:element name="contactInfo" type="tns:ContactInfo"/>
>        <xs:complexType name="ContactInfo">
>                <xs:sequence>
>                        <xs:element name="phone" type="pxtns:PhoneNumber" 
> minOccurs="0"/>
>                </xs:sequence>
>        </xs:complexType>
> </xs:schema>
>
>
>
> I have two problems here:
> 1. when I tried to generate sampel xml,  the child elements of phone
> didn't show up. Can you point out where I'm wrong?
> 2. I realize that phone is still in the target namespace of
> contactInfo. I guess suppose the children of phone will be in proxy
> namespace.
>
> The generated sample xml is like the following:
> <?xml version="1.0" encoding="UTF-8"?>
> <tns:contactInfo
> xsi:schemaLocation="http://www.aa.com/datamodel/account
> accountContact_proxy.xsd"
> xmlns:tns="http://www.aa.com/datamodel/account";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>        <tns:phone/>
> </tns:contactInfo>
>
>
>
> To me it seems like it is the nature of xml schema, you define an
> element inside a sequence, then this element has to be in the same
> namespace as of target namespace, even the child elements are in
> different namespace.   Is it possible that I can make my scenario work
> from schema? I know I'm not fully understand schema yet.
> (my scenario is: I 'm trying to think if I can make author in one
> namespace other than target namespace, and make editor to be in
> another namespace other than target namespace.)
>
>
> Thanks, Helen
>
>
>
>
>
> On Wed, Jul 13, 2011 at 12:28 PM, Geert Josten <[email protected]> 
> wrote:
>> Nice.. :)
>>
>> -----Oorspronkelijk bericht-----
>> Van: [email protected] 
>> [mailto:[email protected]] Namens Joseph Bryan
>> Verzonden: woensdag 13 juli 2011 18:15
>> Aan: General MarkLogic Developer Discussion
>> Onderwerp: Re: [MarkLogic Dev General] question about organizing schema
>>
>> Hi Helen,
>>
>> The XML Schema design pattern that allows you to import a "common"
>> schema and have it inherit the namespace of the schema that imports it
>> is sometimes called a "Chameleon" namespace design.
>>
>> This is achieved by placing the "common" schema in the empty
>> namespace, and using the following method to import it into another
>> schema and apply a namespace to it:
>>
>> <xs:include schemaLocation="common.xsd"/>
>>
>> There is a good write-up of it here:
>> http://www.xfront.com/ZeroOneOrManyNamespaces.html#mixed
>>
>> Thanks.
>>
>> -jb
>>
>>
>> On Wed, Jul 13, 2011 at 12:00 PM, helen chen <[email protected]> wrote:
>>> Hi Geert,
>>>
>>> I played a little bit, I created a common schema with type PhoneNumber
>>> in namespace "http://www.aa.com/datamodel/common"; , and then a
>>> contactInfo schema in namespace "http://www.aa.com/datamodel/account";
>>> which imports the common schema. The schema is  as following:
>>>
>>> common schema:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>>> xmlns:tns="http://www.aa.com/datamodel/common";
>>> targetNamespace="http://www.aa.com/datamodel/common";
>>> elementFormDefault="qualified" attributeFormDefault="qualified">
>>>        <xs:annotation>
>>>                <xs:documentation>This scheme defines common shared data 
>>> object
>>> types.</xs:documentation>
>>>        </xs:annotation>
>>>        <xs:complexType name="PhoneNumber">
>>>                <xs:sequence>
>>>                        <xs:element name="countryCode" type="xs:string"  
>>> minOccurs="0"
>>> maxOccurs="1"/>
>>>                        <xs:element name="areaCode" type="xs:string" 
>>> minOccurs="0" maxOccurs="1"/>
>>>                        <xs:element name="exchange" type="xs:string" 
>>> minOccurs="0" maxOccurs="1"/>
>>>                        <xs:element name="number" type="xs:string" 
>>> minOccurs="0" maxOccurs="1"/>
>>>                        <xs:element name="extension" type="xs:string" 
>>> minOccurs="0" maxOccurs="1"/>
>>>                </xs:sequence>
>>>        </xs:complexType>
>>> </xs:schema>
>>>
>>>
>>> then the contactInfo schema like following:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>>> xmlns:tns="http://www.aa.com/datamodel/account";
>>> xmlns:data-common="http://www.aa.com/datamodel/common";
>>> targetNamespace="http://www.aa.com/datamodel/account";
>>> elementFormDefault="qualified" attributeFormDefault="qualified">
>>>        <xs:annotation>
>>>                <xs:documentation>This schema defines data object types used 
>>> for
>>> interfaces</xs:documentation>
>>>        </xs:annotation>
>>>        <xs:import namespace="http://www.aa.com/datamodel/common";
>>> schemaLocation="common.xsd"/>
>>>        <xs:element name="contactInfo" type="tns:ContactInfo"/>
>>>        <xs:complexType name="ContactInfo">
>>>              <xs:sequence>
>>>                <xs:element name="phone" type="data-common:PhoneNumber" 
>>> minOccurs="0"/>
>>>              </xs:sequence>
>>>        </xs:complexType>
>>> </xs:schema>
>>>
>>>
>>> Then I used XMLspy to create sample xml based on contactInfo schema:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <tns:contactInfo
>>> xsi:schemaLocation="http://www.aa.com/datamodel/account
>>> accountContact.xsd" xmlns:tns="http://www.aa.com/datamodel/account";
>>> xmlns:data-common="http://www.aa.com/datamodel/common";
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>>>        <tns:phone>
>>>                <data-common:countryCode>String</data-common:countryCode>
>>>                <data-common:areaCode>String</data-common:areaCode>
>>>                <data-common:exchange>String</data-common:exchange>
>>>                <data-common:number>String</data-common:number>
>>>                <data-common:extension>String</data-common:extension>
>>>        </tns:phone>
>>> </tns:contactInfo>
>>>
>>>
>>> you can see for contactInfo, the element phone is in the same
>>> namespace of contactinfo, but all the child elements inside phone are
>>> in common namespace.
>>>
>>> This result is not what I want. I think usually I would prefer the
>>> element phone and all its' children are in the same namespace (like
>>> common).
>>>
>>> Did I miss anything here?
>>>
>>> Thanks, Helen
>>>
>>>
>>>
>>> On Wed, Jul 13, 2011 at 2:56 AM, Geert Josten <[email protected]> 
>>> wrote:
>>>> Hi Helen,
>>>>
>>>> I'd recommend to make a shared schema file (more or less your option 2) 
>>>> that contains complex types for things like address and person. When 
>>>> defining an editor, you simply say that the type of that element is that 
>>>> of the complex type person. That way editor will be in its own namespace, 
>>>> but person as type still shareable..
>>>>
>>>> HTH
>>>>
>>>> Kind regards,
>>>> Geert
>>>>
>>>> -----Oorspronkelijk bericht-----
>>>> Van: [email protected] 
>>>> [mailto:[email protected]] Namens helen chen
>>>> Verzonden: dinsdag 12 juli 2011 21:48
>>>> Aan: [email protected]
>>>> Onderwerp: [MarkLogic Dev General] question about organizing schema
>>>>
>>>> Hello there,
>>>>
>>>> I'm learning xml schema, and I have a question that somewhat confuses me.
>>>>
>>>> if I have a structure like the following:
>>>>
>>>> person
>>>>   profile
>>>>        firstname
>>>>        lastname
>>>>        title
>>>>   address
>>>>         street
>>>>         city
>>>>         state
>>>>         zip
>>>>
>>>> in Marklogic, if I have element editor and author, and I want to
>>>> distinguish them in different namespace so when I do search by name, I
>>>> won't mix editor's name and author's name.
>>>>
>>>> I can have two ways to design the schema:
>>>>
>>>> 1.  when I design the schema, I would put editor into one schema with
>>>> one namespace, and put author into another schema with another
>>>> namespace. this way inside document editor and author are seperated by
>>>> namespace. This way can fit the marklogic search.
>>>>
>>>> 2.  just by looking at the structure, I'm very easily to think about
>>>> putting profile and address into a common schema with namespace like
>>>> "common-ns". and then another schema for person, which will import the
>>>> the common schema to reuse the profile element and address element.
>>>> but the person schema usually will be in another namespace.  I have
>>>> this thinking is because I do java a lot and this way seems to make
>>>> element reusable.
>>>>    but the problem for this approach is: since editor and author are
>>>> all type of person, and person will import common schema, so all the
>>>> profiles for editor and author will be in same namespace, then in
>>>> marklogic I won't be able to distinguish them and cannot do search.
>>>>
>>>> Maybe I mixed the schema design with Marklogic.  I'm kind of new to
>>>> schema design, and to me both way seems to have their purpose.
>>>>
>>>> I'm wondering in general when designing schema, do we make reusable
>>>> element in a common schema? if so, then what is best/common way for
>>>> using namespace in schema?
>>>>
>>>> Or in this case, what is the common way to design the schema? Does the
>>>> common way schema design always fit Marklogic?
>>>>
>>>> One idea pops up to me is: maybe Marklogic is for data manipulate, so
>>>> we have one schema for marklogic, and then another schema to be used
>>>> for public.
>>>>
>>>> I hope to get some help on this topic, or maybe point me to some
>>>> articles that describe the common sense of schema design.
>>>>
>>>> Thanks a lot,
>>>> Helen
>>>> _______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> http://developer.marklogic.com/mailman/listinfo/general
>>>> _______________________________________________
>>>> General mailing list
>>>> [email protected]
>>>> http://developer.marklogic.com/mailman/listinfo/general
>>>>
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to