Kurt,
Kurt Sorge wrote:
> Werner,
>
> Thank you for the quick reply.
You are welcome.
> I was thinking it is in the
> binding.xml ...
Yes, it it, indeed.
> or castorbuilder.properties somewhere. I had gone through
> that section of the reference guide the non-trivial example, and the
> pdf file. I guess I missed the part about attributeBinding (I am
> assuming that is what you are pointing me to). If that is the case I
> am still having trouble.
>
> I think I am looking for a more generalized solution. The example I
> give, topic_id, is just one of many attributes and elements with
> underscores in the name. I would find it impractical to map each
> instance in binding.xml and I would wager to guess my team would
> agree with me.
And I would agreed as well; if there's many of them, the solution I am
proposing is not the correct one. But let#s shave this discussion later ....
> I am not an xpath master, maybe I can match on any
> attribute with an underscore, but then I would find it hard to make
> the name camel case correctly.
>
> I have started experimenting with attributeBinding and have not had
> much luck so far. I found Jira #CASTOR-1117 with an example
> binding.xml using attributeBinding. I have a piece of schema that
> looks like:
>
> <xs:element name="widgets"> <xs:complexType> <xs:sequence>
> <xs:element ref="widget" maxOccurs="unbounded" /> </xs:sequence>
> <xs:attribute name="topic_id" type="xs:int" /> </xs:complexType>
> </xs:element>
>
> Now in my binding file I tried:
>
> <attributeBinding name="@topic_id"> <member name="TopicId" />
> </attributeBinding>
>
> with no success. The memeber name still gets generated as
> getTopic_id. I have also tried to move the complex type out of the
> element and then reference the attribute as
> "complexType:cWidgets/@topic_id" like in the example with the same
> result. Am I at least on the right track?
Yes, you are, and here's what I have been using
<attributeBinding name="/widgets/@topic_id">
<member name="topicId" />
</attributeBinding>
which causes the right substitution to take place.
> As a side note, I have been working with Castor for about a week now
> and I am impressed at how easy it is to pick up and use. I would just
> like to get passed this hurdle and another with multiple class
> generation when using <xs:include />, but that can wait for another
> day.
Feel free to throw this at us at any time, even if in parallel.
> Thanks Kurt
>
>
>
> ----- Original Message ---- From: Werner Guttmann
> <[EMAIL PROTECTED]> To: [email protected] Sent:
> Thursday, October 30, 2008 2:57:37 PM Subject: Re: [castor-user]
> Alternative name delimiters in schema
>
> Hi,
>
> how about using a binding file as explained at
>
> http://castor.org/reference/html/xml.code.generator.html#xml.code.generator.custom.bindings
>
>
> to override name resolution during code generation ?
>
> Regards Werner
>
> Kurt Sorge wrote:
>> Hello All-
>>
>> I am doing source code generation from schema files and I am
>> running into some unfriendly method names. The whole problem stems
>> from the fact that the naming convention in the schema uses
>> underscores '_' instead of dashes '-' to delimit words in the
>> attribute and element names. For example the schema uses
>>
>> <xs:attribute name="topic_id" type="xs:string" />
>>
>> instead of
>>
>> <xs:attribute name="topic-id" type="xs:string"/>.
>>
>> When I change the schema to use "topic-id" I get a nice looking
>> method name like getTopicId. Unfortunately, I will not be allowed
>> to change the schema beyond my own sand box so I am getting method
>> names like getTopic_id.
>>
>> I was wondering is it possible to the add/change the mapping
>> delimiters to handle underscores the same as dashes?
>>
>> Thanks Kurt
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email