List Info

Thread: : Incorrect namespaces in generated XML




: Incorrect namespaces in generated XML
user name
2007-05-23 11:23:20
Edit report at h
ttp://pecl.php.net/bugs/bug.php?id=9867&edit=1

 ID:               9867
 Updated by:       mfpphp.net
 Reported By:      mfp at php dot net
 Status:           Assigned
 Id:               9867
 Type:             Bug
 Package:          SCA_SDO
 Operating System: WinXP
 PHP Version:      5.1.6
 Assigned To:      tuscany
 New Comment:

After raising Tuscany JIRA 1231 I found Tuscany JIRA 1112
which I had
raised earlier. 1112 is the JIRA that covers this. It has
been open for
three months though.


Previous Comments:
------------------------------------------------------------
------------

[2007-05-09 05:36:14] phpsoa at gmail dot com

just testing to see to where this comment gets emailed -
please ignore

------------------------------------------------------------
------------

[2007-04-24 13:09:38] mfp at php dot net

My mistake, Tuscany 962 is fixed and not quite the same as
it affects
open types. I have raised JIRA 1231 instead

------------------------------------------------------------
------------

[2007-04-24 11:11:24] mfp at php dot net

Although there are several problems reported here, I think
this is
partly covered by htt
ps://issues.apache.org/jira/browse/TUSCANY-962



In that JIRA, the problem of something being in the default
namespace
when it should be in its own is raised. I think it best to
wait for a
resolution to that and see if any part of this defect still
stands.

------------------------------------------------------------
------------

[2007-01-31 07:21:20] mfp at php dot net

I just came across what I think is another example of this.
Now I
understand better how namespaces work, I suspect it is more
common than
we realise. 



Here's the example in a nutshell:



Catalog.xsd defines a catalog element in the catalogNS
namespace, which
contains items defined in a different namespace in a
different file,
Order.xsd:



<schema xmlns="http://www.w3.
org/2001/XMLSchema"

 xmlns:cat="catalogNS"
xmlns:ord="orderNS"
targetNamespace="catalogNS">

  <include schemaLocation="Order.xsd"/>

  <element name="catalog"
type="cat:CatalogType"/>

  <complexType name="CatalogType">

    <sequence>

      <element maxOccurs="unbounded"
ref="ord:item"/>

    </sequence>

  </complexType>       

</schema>



Order.xsd defines the item element as being in the
"OrderNS"
namespace:

.../...

<schema xmlns="http://www.w3.
org/2001/XMLSchema"

xmlns:ord="orderNS"
xmlns:cust="customerNS"
targetNamespace="orderNS">

.../...

  <element name="item">

.../...



but when you build a catalog and write it out, although a
namespace
prefix is defined for "orderNS", everything is in
the default namespace,
"catalogNS":





<catalog xmlns="catalogNS"
xmlns:tns="catalogNS"
xmlnssi=&q
uot;http:
//www.w3.org/2001/XMLSchema-instance"
xmlns:tns2="orderNS">

  <item>

.../...

------------------------------------------------------------
------------

[2007-01-18 08:46:57] mfp at php dot net

Description:
------------
I have been quite sceptical about the XML that SDO is
producing when it
builds a SOAP request, especially w.r.t. the namespaces. So
I tried
loading the XML that SDO is producing into Java XERCES with
validation
on. There are several problems with the XML generated, I
think.



Using the two xsds that are in the reproduce section below,
and the
short PHP script also there, SDO generates:



<?xml version="1.0"
encoding="UTF-8"?>

<BOGUS xmlns="http://Component"
xmlns:tns="http://Component"
xmlns:tns2="http://www.test.com/in
fo"
xmlnssi=&q
uot;http:
//www.w3.org/2001/XMLSchema-instance"
xsi:type="add">

  <person>

    <tns2:name>

      <first>Will</first>

      <last>Shakespeare</last>

    </tns2:name>

  </person>

</BOGUS>



There are three (!) things wrong with this.

1. XERCES will not accept the xsi:type="add". I do
not really know why.
I assume this is because there is no type called
"add", it's only an
element. So I do not think this should be coming out. 



2. name should not be in tns2=http://www.test.com/info
, neither should
"first" and "last" be in the default
namespace of http://Component. The
person.xsd has no elementFormDefault, so the elements below
<person>
should all ne in the no name namespace. 



3.You have to change the person.xsd to see the third thing:
put
ElementNameDefault="qualified" in

the person schema, then "name", "first"
and "last" should all now be
coming out in the http://www.test.com/info
namespace, but it makes no
difference to the generated XML. 

Reproduce code:
---------------
<?php

$xmldas = SDO_DAS_XML::create('types.xsd');

$person =
$xmldas->createDataObject('http://www.test.com/info
','personType');

$name = $person->createDataObject('name');

$name->first = "Will";

$name->last  = "Shakespeare";

$add = $xmldas->createDataObject('http://Component','add');

$add->person = $person;

$xdoc   = $xmldas->createDocument('', 'BOGUS', $add);

$xmlstr = $xmldas->saveString($xdoc, 2);

echo $xmlstr;

?>



types.xsd:

    <xs:schema xmlnss=&qu
ot;http://www.w3.
org/2001/XMLSchema" 

      xmlns:ns0="http://www.test.com/in
fo"

      targetNamespace="http://Component"

      elementNameDefault="qualified">

      <xs:import schemaLocation="person.xsd"
namespace="http://www.test.c
om/info"/>

      <xs:element name="add">

        <xs:complexType>

          <xs:sequence>

            <xs:element name="person"
type="ns0:personType"
nillable="true"/>

          </xs:sequence>

        </xs:complexType>

      </xs:element>

    </xs:schema>



person.xsd:

<?xml version="1.0"
encoding="UTF-8"?>

<schema xmlns="http://www.w3.
org/2001/XMLSchema" 

    targetNamespace="http://www.test.com/in
fo" 

    xmlns:info="http://www.test.co
m/info">

    <complexType name="nameType">

		<sequence>

			<element name="first"
type="string"></element>

			<element name="last"
type="string"></element>

		</sequence>

	</complexType>

	<complexType name="personType">

		<sequence>

			<element name="name"
type="info:nameType"></element>

		</sequence>

	</complexType>	

</schema>

Expected result:
----------------
see above

Actual result:
--------------
see above

------------------------------------------------------------
------------


-- 
Edit this bug report at h
ttp://pecl.php.net/bugs/bug.php?id=9867&edit=1


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "phpsoa" group.
To post to this group, send email to phpsoagooglegroups.com
To unsubscribe from this group, send email to
phpsoa-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.co.uk/group/phpsoa?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )