Pete --
I've just given a shot at what you'vesuggested by imbeding my XML elements
in others so they have valid xpaths.
However, the SourceGenerator doesn't seem to have a '-binding-file'
option:
D:\dev\dev_G101\App\src\WCT\example>castor.bat --help
Invalid command line option -binding-file
Usage: -i filename [-package package-name] [-dest dest-dir]
[-line-separator ( unix | mac | win)] [-f ] [-h ]
[-verbose ] [-nodesc ] [-types types] [-type-factory classname]
[-nomarshall ] [-testable ] [-sax1 ]
Also, if my elements are located off of the schema element:
<schema...
<option...
<amenities
Should the xpath specified in the binding file be /option/amenities or
/schema/option/amenities ?
Thx,
Aurangzeb
On Wed, 5 Feb 2003, Pete Thomas wrote:
:If you just want to be able to have two elements with the same name and then
:use the SourceGenerator to generate the java classes, then you need to
:provide an override for the normal Java class name - otherwise you'll end up
:with two classes generated but the last will overwrite the first.
:
:Specify the override in a binding file, e.g
:
:bindingDuplicates.xml :-
:
:
:<?xml version="1.0"?>
:<!-- This file contains the binding information -->
:<!-- for the invoice XML Schema -->
:<!-- It is meant to be used by the Castor Source Code Generator -->
:
:<cbf:binding xmlns:cbf="http://www.castor.org/SourceGenerator/Binding"
: defaultBindingType='element'>
:
: <!-- Binding the element to a class -->
: <cbf:elementBinding name="/CTP/AIP/REQUEST">
: <cbf:java-class name="RequestAIP"/>
: </cbf:elementBinding>
:
: <!-- Binding the element to a class -->
: <cbf:elementBinding name="/CTP/FAF/REQUEST">
: <cbf:java-class name="RequestFAF"/>
: </cbf:elementBinding>
:
:</cbf:binding>
:
:
:where name= is the xpath to the duplicated element
:
:then pass this binding file into the SourceGenerator e.g.
:
:java -classpath %JAVACLASSPATH% org.exolab.castor.builder.SourceGenerator -i
:C:/XML/XMLSchemas/your.xsd -package com.yourpackage -dest src -types j2
:-binding-file bindingDuplicates.xml
:
:
:when you marshall back to XML the original element name will be intact. It
:took me ages to get this working, it really should be documented somewhere.
:
:
:Pete
:
:
:
:-----Original Message-----
:From: Aurangzeb M. Agha [mailto:[EMAIL PROTECTED]]
:Sent: 05 February 2003 15:29
:To: [EMAIL PROTECTED]
:Subject: Re: [castor-dev] Can two XML elements with same name but
:different structures exist seperately?
:
:
:Thanks for the reply Sandor.
:
:I realized that I don't think this solution will work if other elements
:reference overview or generalInfo. Is there a way to accomplish this,
:that is allowing for these elements to be accessible outside the scope of
:'hotelInfo', as well?
:
:Also, a similar, but seperate question: what if the two child elements an
:element (call it, a) have different structures but the same name?
:
: Rgs,
: Zeb
:
::On Tue, 4 Feb 2003, Sandor KELEMEN wrote:
::
:::> I've been given an XML spec by a hotel provider for access to their
:::> system.
:::>
:::> In it, they define two elements, 'overview' and 'generalInfo'. Both of
:::> these elements are children of a mutual parent, 'hotelInfo'. However,
:::> according to their spec, 'overview' has a child element ALSO called
:::> 'generalInfo', but one with a different contents than the 'generalInfo'
:::> which is at the same level as 'overview'.
:::>
:::> First question: Is this legit?
:::
:::Yes.
:::
:::
:::> Second question: If so, how do you map this in a .xsd file?
:::
:::Here are two possible solutions:
:::
:::1.
:::----------------------------------------------------
:::<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
:::elementFormDefault="qualified" attributeFormDefault="unqualified">
::: <xsd:element name="hotelInfo">
::: <xsd:complexType>
::: <xsd:sequence>
:::
::: <xsd:element name="overview">
::: <xsd:complexType>
::: <xsd:sequence>
::: <xsd:element name="generalInfo">
::: <xsd:complexType>
::: <xsd:sequence>
::: <xsd:element name="numBedrooms" type="xsd:string"/>
::: <xsd:element name="numFloors" type="xsd:string"/>
::: </xsd:sequence>
::: </xsd:complexType>
::: </xsd:element>
::: </xsd:sequence>
::: </xsd:complexType>
::: </xsd:element>
:::
::: <xsd:element name="generalInfo">
::: <xsd:complexType>
::: <xsd:sequence>
::: <xsd:element name="hotelId" type="xsd:string"
:minOccurs="1"/>
::: <xsd:element name="name" type="xsd:string" minOccurs="1"/>
::: <xsd:element name="streetAddress1" type="xsd:string"
:::minOccurs="1"/>
::: <xsd:element name="streetAddress2" type="xsd:string"
:::minOccurs="0"/>
::: <xsd:element name="city" type="xsd:string" minOccurs="1"/>
::: <xsd:element name="postalCode" type="xsd:string"
:::minOccurs="1"/>
::: <xsd:element name="stateCode" type="xsd:string"
:::minOccurs="1"/>
::: </xsd:sequence>
::: </xsd:complexType>
::: </xsd:element>
::: </xsd:sequence>
::: </xsd:complexType>
::: </xsd:element>
:::</xsd:schema>
:::----------------------------------------------------
:::
:::2.
:::----------------------------------------------------
:::<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
:::elementFormDefault="qualified" attributeFormDefault="unqualified">
:::
::: <xsd:element name="hotelInfo">
::: <xsd:complexType>
::: <xsd:sequence>
:::
::: <xsd:element name="overview">
::: <xsd:complexType>
::: <xsd:sequence>
::: <xsd:element name="generalInfo" type="OverviewGeneralInfo"/>
::: </xsd:sequence>
::: </xsd:complexType>
::: </xsd:element>
:::
::: <xsd:element name="generalInfo" type="HotelInfoGeneralInfo"/>
::: </xsd:sequence>
::: </xsd:complexType>
::: </xsd:element>
:::
::: <xsd:complexType name="OverviewGeneralInfo">
::: <xsd:sequence>
::: <xsd:element name="numBedrooms" type="xsd:string"/>
::: <xsd:element name="numFloors" type="xsd:string"/>
::: </xsd:sequence>
::: </xsd:complexType>
:::
::: <xsd:complexType name="HotelInfoGeneralInfo">
::: <xsd:sequence>
::: <xsd:element name="hotelId" type="xsd:string" minOccurs="1"/>
::: <xsd:element name="name" type="xsd:string" minOccurs="1"/>
::: <xsd:element name="streetAddress1" type="xsd:string" minOccurs="1"/>
::: <xsd:element name="streetAddress2" type="xsd:string" minOccurs="0"/>
::: <xsd:element name="city" type="xsd:string" minOccurs="1"/>
::: <xsd:element name="postalCode" type="xsd:string" minOccurs="1"/>
::: <xsd:element name="stateCode" type="xsd:string" minOccurs="1"/>
::: </xsd:sequence>
::: </xsd:complexType>
:::
:::</xsd:schema>
:::----------------------------------------------------
:::
:::best regards,
:::Sanyi
:::
:::-----------------------------------------------------------
:::If you wish to unsubscribe from this mailing, send mail to
:::[EMAIL PROTECTED] with a subject of:
::: unsubscribe castor-dev
:::
::
::
:
:
--
Aurangzeb M. Agha | Email : [EMAIL PROTECTED]
| Home : +3 010 8959.558
34 Nafsika St. | Direct: +3 010 8995.875
Voula 16673 | Mobile: TBD
Greece | e-Fax : 978 246.0770
| PGP id: 0x68B3A763
"Those who would give up essential liberty to purchase a little
temporary safety deserve neither liberty nor safety."
- Benjamin Franklin
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev