  | |  | Getting the namespace prefix | Getting the namespace prefix 2003-07-31 - By Nick Betteridge
I'm having difficulty in trying to get the namespace prefix.
When I get the SchemaGrammar and recurse down through the model, when I get to the simpleTypes (eg "xs:string") I can recover both the name and the namespace of the simpleType, but I can't work out how to recover the namespace prefix.
ie xsSimpleTypeDecl.getName() will give me "string" xsSimpleTypeDecl.getNamespace() will give me http://www.w3.org/2001/XMLSchema
how do I get "xs" (defined in the example below)
I would be very grateful if someone would point me in the right direction.
Many trhanks Nick
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > <xs:element name="responsemodel"> <xs:annotation> <xs:documentation>filesystems response model</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="response" type="xs:string"/> <xs:element name="exceptionThrown" type="xs:boolean"/> <xs:element name="exceptionMessage" minOccurs="0" type="xs :string"/> <xs:sequence> <xs:element name="children" minOccurs="0" maxOccurs="unbounded" type="xs:string"/> </xs:sequence> <xs:element name="booleanResponse" minOccurs="0" type="xs :boolean"/> <xs:element name="byteResponse" minOccurs="0" type="xs :base64Binary"/> <xs:element name="calendarResponse" minOccurs="0" type="xs:date "/> <xs:element name="longResponse" minOccurs="0" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.2800.1170" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2>I'm having difficulty in trying to get the namespace prefix.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>When I get the SchemaGrammar and recurse down through the model, when I get to the simpleTypes (eg "xs:string") I can recover both the name and the namespace of the simpleType, but I can't work out how to recover the namespace prefix.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>ie</FONT></DIV> <DIV><FONT face=Arial size=2>xsSimpleTypeDecl.getName() will give me "string"</FONT></DIV> <DIV><FONT face=Arial size=2>xsSimpleTypeDecl.getNamespace() will give me <A href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A>< /FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>how do I get "xs" (defined in the example below)</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>I would be very grateful if someone would point me in the right direction.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>Many trhanks</FONT></DIV> <DIV><FONT face=Arial size=2>Nick</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2><?xml version="1.0" encoding="UTF-8"?><BR><xs:schema <BR> xmlns:xs="<A href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A>" <BR> ><BR> <xs:element name="responsemodel"><BR> <xs:annotation><BR> <xs:documentation>filesystems response model</xs:documentation><BR> </xs:annotation><BR> <xs:complexType><BR>   ; <xs:sequence><BR> <xs:element name="response" type="xs:string"/><BR> <xs:element name="exceptionThrown" type="xs:boolean"/><BR>   ; <xs:element name="exceptionMessage" minOccurs="0" type="xs:string"/><BR> <xs:sequence><BR> <xs:element name="children" minOccurs="0"<BR> maxOccurs="unbounded" type="xs:string"/><BR> </xs:sequence><BR> <xs:element name="booleanResponse" minOccurs="0" type="xs:boolean"/><BR>   ; <xs:element name="byteResponse" minOccurs="0" type="xs:base64Binary"/><BR> <xs:element name="calendarResponse" minOccurs="0" type="xs:date"/><BR> <xs:element name="longResponse" minOccurs="0" type="xs:int"/><BR> </xs:sequence><BR> </xs:complexType><BR> </xs:element><BR></xs:schema></FONT></DIV></BODY></HTML>
|
|
 |