You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Dave Cherkassky <dc...@djinnsoft.com> on 2010/07/15 17:53:45 UTC
Namespaces for attributes
Here's something unexpected -- perhaps someone can explain...
1) The XSD is:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
targetNamespace="http://springboardproducts.com/rram-json/2009/11/11/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:rram-json="http://springboardproducts.com/rram-json/2009/11/11/">
...
<xs:attribute name="attributeByReference" type="xs:string" />
<xs:complexType name="ContributorReferenceType">
...
<xs:attribute ref="rram-json:attributeByReference"/>
<xs:attribute name="attributeByName" type="xs:string" />
</xs:complexType>
...
</xs:schema>
2) Run the wsdl2java code generation with the following arguments:
org.apache.axis2.wsdl.WSDL2Java
-uri file://...
-p com.springboardproducts.services.doc.json
-o ../temp/services/json/doc
-ns2p http://springboardproducts.com/rram-json/2009/11/11/=com.springboardproducts.rram.doc.axis2._20091111.json
-s
-ss
-sd
-Euwc
--service-name JsonTrainingElementCommentService
-or
3) Get code like this (formatted for readability withing email):
package com.springboardproducts.rram.doc.axis2._20091111.json;
public class ContributorReferenceType
implements org.apache.axis2.databinding.ADBBean{
/* This type was generated from the piece of schema that had
name = ContributorReferenceType
Namespace URI = http://springboardproducts.com/rram-json/2009/11/11/
Namespace Prefix = ns1
*/
...
public void serialize(final javax.xml.namespace.QName parentQName,
final org.apache.axiom.om.OMFactory factory,
org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter,
boolean serializeType)
throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{
...
if (localAttributeByReference != null){
writeAttribute("http://springboardproducts.com/rram-json/2009/11/11/",
"attributeByReference",
org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localAttributeByReference), xmlWriter);
}
...
if (localAttributeByName != null){
writeAttribute("",
"attributeByName",
org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localAttributeByName), xmlWriter);
}
...
}
...
}
4) So, my question is:
How come if I specify the attribute by reference
ie.: <xs:attribute ref="rram-json:attributeByReference"/>
then it lives within a namespance
ie.: writeAttribute("http://springboardproducts.com/rram-json/2009/11/11/", ...
But if I specify the name explicitly
ie. <xs:attribute name="attributeByName" type="xs:string" />
then no namespace is provided.
ie.: writeAttribute("", ...
I would have expected both to have a namespace. Perhaps I missed a subtle detail in the XSD spec? Perhaps I misunderstood AXIS2 code generation? Perhaps it is a bug?
If someone can explain, you insight would be appreciated.
Many thanks in advance,
--
Dave Cherkassky
VP of Software Development
DJiNN Software Inc.
416.504.1354
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org