[xsd-users] Using regular expressions
Boris Kolpackov
boris at codesynthesis.com
Thu Oct 8 12:48:33 EDT 2009
Hi Carl,
Carl <xsd at faultline.com> writes:
> Here is an example of what I am trying to do:
>
> The files StateWH.xsd and StateUI.xsd both contain an element called
> AmendedReturnElect among many others.
> So after much trial and error I came up with this regular expression
> in the hopes that all classes in the StateWH file would have WH_
> prepended to the names.
>
> --anonymous-regex ,.*StateWH.xsd .* StateWHType/.*,WH_$0,
Because the file name in the pattern is empty for the file that is
being compiled, you will need to use this expressions:
--anonymous-regex ,.* .* StateWHType/(.*),WH_$1,
It will cover both cases: when StateWH.xsd is the file that is being
compiled and when StateWH.xsd is imported/included from other schemas.
BTW, you can use the --anonymous-regex-trace option to see what your
expressions are applied to and whether they match. Useful for
debugging.
The above approach will require a separate expression for each schema
file and can become a bit tedious. If you don't mind using a more
"regular" naming scheme then you can cover all your schema files with
one expression. For example, this regex:
--anonymous-regex ',.* .* (.*)/(.*),$1_$2,'
Will name all your anonymous types like StateWHType_AmendedReturnElect,
StateUIType_AmendedReturnElect, etc.
Let us know if this doesn't work you.
Boris
More information about the xsd-users
mailing list