|
RE: Prefix question: msg#00084text.xml.xmlbeans.user
I thought that the attribute xmlns:ga="http://ga.afl.com/" in the <xs:schema> tag reflects that. Isn’t that true? Nope, that just declares a namespace. AFAIK, there's is no way within an XSD to require an element be qualified using a prefix. I also thought most parsers would consider this <readGroupRequest xmlns="http://ga.afl.com/"> and <ga:readGroupRequest xmlns:ga="http://ga.afl.com/"> to be the same. Why does the XML need to have this prefix? Also, I'm not sure setSaveSuggestedPrefixes will do what you need, try, setAggressivePrfixes (?) -----Original Message----- From: Dogan Atay [mailto:DAtay@xxxxxxxxx] Sent: Tue 1/11/2005 2:30 PM To: user@xxxxxxxxxxxxxxxxxxx Cc: Subject: RE: Prefix question Justin, I think I have asked my question in a wrong way. My application is NOT dependent on ‘ga’ prefix. The output xml of <readGroupRequest xmlns="http://ga.afl.com/"> <groupNumber>12345</groupNumber> </readGroupRequest> is namespace qualified with a no-prefix. That is fine. My schema shows that this namespace is qualified with the ‘ga’ prefix. I thought that the attribute xmlns:ga="http://ga.afl.com/" in the <xs:schema> tag reflects that. Isn’t that true? My question is that when I call getName().getPrefix() for this QName why is ‘ga’ not shown? Thanks, Dogan Atay _____ Parsers are free to choose their own prefixes (or none at all). Why is your application dependent on the prefix "ga"? The URI to which this prefix points is what's important, not the prefix itself. - Justin From: Dogan Atay Sent: Tuesday, January 11, 2005 4:46 PM To: user@xxxxxxxxxxxxxxxxxxx Subject: Prefix question I have a schema like the following <xs:schema targetNamespace="http://ga.afl.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:ga="http://ga.afl.com/" xmlns:png="http://ga.afl.com/png/" xmlns:pnr="http://ga.afl.com/pnr/" xmlns:ct="http://es.afl.com/ct/"> <xs:import namespace=http://es.aflc.com/ct/ schemaLocation="ct.xsd"/> <xs:import namespace="http://ga.afl.com/png/" schemaLocation="Png.xsd"/> <xs:import namespace="http://ga.afl.com/pnr/" schemaLocation="Pnr.xsd"/> <xs:element name="readGroupRequest" type="ga:GroupIdentifierType"/> <xs:complexType name="GroupIdentifierType"> <xs:choice> <xs:element name="pngId" type="xs:integer"/> <xs:element name="batchId" type="png:BatchIDType"/> <xs:element name="groupNumber" type="ct:GroupNumberType"/> </xs:choice> </xs:complexType> </xs:schema> After the schema is compiled I do the following SchemaType type = ReadGroupRequestDocument.type; SchemaProperty[] schemaProperties = type.getElementProperties(); for(int i=0; i < schemaProperties.length; i++) { SchemaProperty schemaProperty = schemaProperties[i]; QName qName = schemaProperty.getName(); System.out.println("NamespaceURI: " + qName.getNamespaceURI()); System.out.println("LocalPart: " + qName.getLocalPart()); System.out.println("Prefix: " + qName.getPrefix()); } The output of that code is NamespaceURI: http://ga.afl.com/ LocalPart: readGroupRequest Prefix: What I do not understand is why the prefix is not “ga”. The schema has this information. I need to get this information out of the schema because the xml I generate must have this prefix. I will use XMLOptions setSaveSuggestedPrefixes() method but I do not want to hardcode a prefix in my source code. How else can I get the prefix from the schema? Thanks, Dogan Atay |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Prefix question: 00084, Dogan Atay |
|---|---|
| Next by Date: | RE: Prefix question: 00084, Dmitri . Colebatch |
| Previous by Thread: | RE: Prefix questioni: 00084, Dogan Atay |
| Next by Thread: | RE: Prefix question: 00084, Dmitri . Colebatch |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |