Hi! [My apologies if this main appears twice]
I've been using XMLBeans for some time on the Astrogrid project (see http://www.astrogrid.org), which is a UK-based astronomy project and part of the International Virtual Observatory Alliance (http://www.ivoa.net). I've been involved in implementing ADQL, the Astronomical Data Query Language. We have emerging standards for ADQL, including an intermediate form in XML. The intermediate form is used in a process of transforming ADQL to some SQL dialect that a data center holding atronomical archives can then use in executing a query. The idea is to have a standardized language that all astronomers can use to query against remote and distributed archives. XMLBeans has been of great value (at least on the Astrogrid project) in making the implementation side easier to accomplish. I'm really impressed. But I've one small annoying problem, and wondered whether someone could help, or point out any oversight that I have made. We have a number of schemas, but I'll simplify. The problem revolves around namespaces, which I'm sure won't come as a surprise! Until recently our schema began something like this... <xs:schema targetNamespace="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:adql="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" elementFormDefault="qualified"> Lately we have been experimenting with standardizing namespaces on urns. The above might then become <xs:schema targetNamespace="urn:astrogrid:schema:ADQL:v1.0" xmlns:adql="urn:astrogrid:schema:ADQL:v1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" elementFormDefault="qualified"> All of the types defined within the schema are at global level. And I've had no problems with generating valid documents, either through the use of a parser that parses SQL-like strings or via a gui tool programmed in Swing. Both use XMLBeans. When I do a pretty print of a document using the first of the above schemas, I get something like <v1:Select xmlns:v1="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <v1:SelectionList> <v1:Item xsi:type="v1:allSelectionItemType"/> </v1:SelectionList> <v1:From> <v1:Table Name="RASS_PHOTONS" Alias="r" xsi:type="v1:tableType"/> </v1:From> <v1:Where> <v1:Condition Comparison="<=" xsi:type="v1:comparisonPredType"> <v1:Arg Oper="*" xsi:type="v1:binaryExprType"> <v1:Arg xsi:type="v1:atomType"> <v1:Literal Value="2" xsi:type="v1:integerType"/> </v1:Arg> <v1:Arg xsi:type="v1:trigonometricFunctionType" Name="ASIN"> and so on When I use the second of the above schemas, I get <urn:Select xmlns:urn="urn:astrogrid:schema:ADQL:v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <urn:SelectionList> <urn:Item xsi:type="urn:allSelectionItemType"/> </urn:SelectionList> <urn:From> <urn:Table xsi:type="urn:tableType" Name="RASS_PHOTONS" Alias="r"/> </urn:From> <urn:Where> <urn:Condition xsi:type="urn:comparisonPredType" Comparison="<="> <urn:Arg xsi:type="urn:binaryExprType" Oper="*"> <urn:Arg xsi:type="urn:atomType"> <urn:Literal Value="2" xsi:type="urn:integerType"/> </urn:Arg> <urn:Arg xsi:type="urn:trigonometricFunctionType" Name="ASIN"> and so on. The actual examples are too large to include all. There is a lot of XMLBeans manipulation undertaken to get this far, and the code appears efficient in memory and execution. In both examples the namespace prefix leaves something to be desired: I would like some more meaningful prefix (like "adql"). I've experimented quite a bit with XmlOptions, but with only partial success. For example, this code... HashMap schemaPrefixes = new HashMap() ; schemaPrefixes.put( "urn:astrogrid:schema:ADQL:v1.0", "adql" ) ; XmlOptions opts = new XmlOptions();opts.setSaveOuter() ; opts.setSaveSuggestedPrefixes( schemaPrefixes ) ; opts.setSaveNamespacesFirst() ; opts.setSaveAggressiveNamespaces() ; opts.setSavePrettyPrint() ; opts.setSavePrettyPrintIndent(4) ; return exec().xmlText(opts) ; run using XMLBeans compiled against schema two above, produces... <adql:Select xmlns:adql="urn:astrogrid:schema:ADQL:v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <adql:SelectionList> <urn:Item xsi:type="urn:allSelectionItemType"/> </adql:SelectionList> <adql:From> <urn:Table xsi:type="urn:tableType" Name="RASS_PHOTONS" Alias="r"/> </adql:From> <adql:Where> <urn:Condition xsi:type="urn:comparisonPredType" Comparison="<="> <urn:Arg xsi:type="urn:binaryExprType" Oper="*"> <urn:Arg xsi:type="urn:atomType"> <urn:Literal Value="2" xsi:type="urn:integerType"/> </urn:Arg> <urn:Arg xsi:type="urn:trigonometricFunctionType" Name="ASIN"> What am I doing wrong? What else can I try to overcome this aesthetically? Finally, I'd like to ask why the original prefixes cannot be preserved? I can see where the prefixes used in the print are coming from, and obviously prefixes are simply a convenience. I can get around the problem on a makeshift basis simply by changing the namespace strings. Thanks for your help And regards Jeff -- Jeff Lusted tel: +44 (0)116 252 5358 Astrogrid Project mob: +44 (0)7973 492290 Dept Physics & Astronomy email: [EMAIL PROTECTED] University of Leicester web: http://www.astrogrid.org --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]