How can I access a property containing a hyphen (i.e. "portfolio-id")

View: New views
11 Messages — Rating Filter:   Alert me  

How can I access a property containing a hyphen (i.e. "portfolio-id")

by Harm Bandstra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello All,

I'm not sure if this is the right place for my question, but here
goes...

I have an XSD file with properties containing hyphens. I can't get it
to accept any changes to the properties. In part this is because php
doesn't accept hypens in variable names, but I found that "Simple-XML"
uses some sort of work around. I have the following php code:

===

$xmldas = SDO_DAS_XML::create('xsd/pre_qual_wso.xsd');
$messagebody = $xmldas->createDataObject('','MessagebodyType');

// This gives a syntax error (duh)
$messagebody->portfolio-id     = 'BST';

// These 2 give the following error:
// Problem creating an XML document: DataObjectImpl::setSDOValue -
path not found:
$messagebody['portfolio-id']   = 'BST';
$messagebody[0]                = 'BST';

// This is the way it's done in simple-xml, but also doesn't work
$messagebody->{'portfolio-id'} = 'BST';

===

Can it be done? Any help will be appreciated.


Kind regards,

Harm Bandstra


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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by Simon Laws :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On 9 Nov, 20:16, Harm Bandstra <hbands...@...> wrote:

> Hello All,
>
> I'm not sure if this is the right place for my question, but here
> goes...
>
> I have an XSD file with properties containing hyphens. I can't get it
> to accept any changes to the properties. In part this is because php
> doesn't accept hypens in variable names, but I found that "Simple-XML"
> uses some sort of work around. I have the following php code:
>
> ===
>
> $xmldas = SDO_DAS_XML::create('xsd/pre_qual_wso.xsd');
> $messagebody = $xmldas->createDataObject('','MessagebodyType');
>
> // This gives a syntax error (duh)
> $messagebody->portfolio-id     = 'BST';
>
> // These 2 give the following error:
> // Problem creating an XML document: DataObjectImpl::setSDOValue -
> path not found:
> $messagebody['portfolio-id']   = 'BST';
> $messagebody[0]                = 'BST';
>
> // This is the way it's done in simple-xml, but also doesn't work
> $messagebody->{'portfolio-id'} = 'BST';
>
> ===
>
> Can it be done? Any help will be appreciated.
>
> Kind regards,
>
> Harm Bandstra

Hi Harm

Yep,  you found the right place to ask the question. I don't know the
answer off the top of my head and I'm in the middle of rebuilding my
PHP environment today so I'll take a look when I get it sorted. Sorry
about the slight delay. I'll get back to you shortly.

In the mean tim, if anyone else knows the answer feel free to jump
in:-)

Regards

Simon


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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by Simon Laws :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On 9 Nov, 21:21, simonsl...@... wrote:

> On 9 Nov, 20:16, Harm Bandstra <hbands...@...> wrote:
>
>
>
> > Hello All,
>
> > I'm not sure if this is the right place for my question, but here
> > goes...
>
> > I have an XSD file with properties containing hyphens. I can't get it
> > to accept any changes to the properties. In part this is because php
> > doesn't accept hypens in variable names, but I found that "Simple-XML"
> > uses some sort of work around. I have the following php code:
>
> > ===
>
> > $xmldas = SDO_DAS_XML::create('xsd/pre_qual_wso.xsd');
> > $messagebody = $xmldas->createDataObject('','MessagebodyType');
>
> > // This gives a syntax error (duh)
> > $messagebody->portfolio-id     = 'BST';
>
> > // These 2 give the following error:
> > // Problem creating an XML document: DataObjectImpl::setSDOValue -
> > path not found:
> > $messagebody['portfolio-id']   = 'BST';
> > $messagebody[0]                = 'BST';
>
> > // This is the way it's done in simple-xml, but also doesn't work
> > $messagebody->{'portfolio-id'} = 'BST';
>
> > ===
>
> > Can it be done? Any help will be appreciated.
>
> > Kind regards,
>
> > Harm Bandstra
>
> Hi Harm
>
> Yep,  you found the right place to ask the question. I don't know the
> answer off the top of my head and I'm in the middle of rebuilding my
> PHP environment today so I'll take a look when I get it sorted. Sorry
> about the slight delay. I'll get back to you shortly.
>
> In the mean tim, if anyone else knows the answer feel free to jump
> in:-)
>
> Regards
>
> Simon

Hi Harm

Sorry this took me a while to get to. Have just managed to get my dev
environment up on my new machine following the demise of my old one.
The reason that this is failing is that the Tuscany SDO implementation
that we rely on for SDO support doesn't recognize the "-" character as
a valid character in a name. I think that it should in as much that it
is a valid name character [1]. Can you raise a bug report on this and
I'll log it in Tuscany and make a change. I can make the change
locally on PECL in the first instance. If people have doubts about
this then let me know.

Thanks

Simon


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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by pscott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Wed, 2007-11-14 at 04:44 -0800, simonslaws@... wrote:
> I'll log it in Tuscany and make a change. I can make the change
> locally on PECL in the first instance. If people have doubts about
> this then let me know.
>

I have some serious doubts about that... Modifying to cater for
hyphenated names is asking for trouble - kind of like modifying SQL
standards to let people create reserved word field names...

--Paul


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


All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by Simon Laws :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On 14 Nov, 12:48, Paul Scott <psc...@...> wrote:

> On Wed, 2007-11-14 at 04:44 -0800, simonsl...@... wrote:
> > I'll log it in Tuscany and make a change. I can make the change
> > locally on PECL in the first instance. If people have doubts about
> > this then let me know.
>
> I have some serious doubts about that... Modifying to cater for
> hyphenated names is asking for trouble - kind of like modifying SQL
> standards to let people create reserved word field names...
>
> --Paul
>
> All Email originating from UWC is covered by disclaimerhttp://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm

Hi Paul

My reference [1] should have been (http://www.w3.org/TR/REC-xml/#NT-
NameChar).

>From this it looks to me like "-" can validly appear in the XML names,
but not the first character. I don't see anything in the SDO C++ spec
that describes the character set that forms property names in SDO
other than by implication through its discussion of XPath. There is a
danger here that looking in a spec for something that maybe excluded
is always problematic.

Are you suggesting that the "-" character should not appear in
property names? One view would be to rule it out because it causes
particular problems in PHP scripts. However that approach presents
problems for people what to use existing schema. While the object->my-
property syntax won't work you could expect the object['my-property']
or object->{'my-property'} to work.

Regards

Simon


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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by Harm Bandstra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Simon,

I filed a bug report here: http://pecl.php.net/bugs/bug.php?id=12443

Thank you for your help.

Regards,

Harm

On Nov 14, 2:40 pm, simonsl...@... wrote:

> On 14 Nov, 12:48, Paul Scott <psc...@...> wrote:
>
> > On Wed, 2007-11-14 at 04:44 -0800, simonsl...@... wrote:
> > > I'll log it in Tuscany and make a change. I can make the change
> > > locally on PECL in the first instance. If people have doubts about
> > > this then let me know.
>
> > I have some serious doubts about that... Modifying to cater for
> > hyphenated names is asking for trouble - kind of like modifying SQL
> > standards to let people create reserved word field names...
>
> > --Paul
>
> > All Email originating from UWC is covered by disclaimerhttp://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
> Hi Paul
>
> My reference [1] should have been (http://www.w3.org/TR/REC-xml/#NT-
> NameChar).
>
> >From this it looks to me like "-" can validly appear in the XML names,
>
> but not the first character. I don't see anything in the SDO C++ spec
> that describes the character set that forms property names in SDO
> other than by implication through its discussion of XPath. There is a
> danger here that looking in a spec for something that maybe excluded
> is always problematic.
>
> Are you suggesting that the "-" character should not appear in
> property names? One view would be to rule it out because it causes
> particular problems in PHP scripts. However that approach presents
> problems for people what to use existing schema. While the object->my-
> property syntax won't work you could expect the object['my-property']
> or object->{'my-property'} to work.
>
> Regards
>
> Simon


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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by monxton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Paul Scott wrote:
> On Wed, 2007-11-14 at 04:44 -0800, simonslaws@... wrote:
>> I'll log it in Tuscany and make a change. I can make the change
>> locally on PECL in the first instance. If people have doubts about
>> this then let me know.
>>
>
> I have some serious doubts about that... Modifying to cater for
> hyphenated names is asking for trouble - kind of like modifying SQL
> standards to let people create reserved word field names...

Paul, not sure where you're coming from here - I think this really
should work. There's no issue from the PHP point of view; this stuff is
documented under the "Variable variables" section of the manual
(http://php.net/manual/en/language.variables.variable.php), and the syntax

    $my_object->{'weird-characters-here'} = "some text";

is perfectly respectable. And Simon has pointed us at the relevant
section of the XML spec (http://www.w3.org/TR/REC-xml/#NT-NameChar).
It's just a shame that Tuscany is barfing on it at present (I think it's
Tuscany rather than libxml, as borne out but Harm's successful use of
this syntax with simplexml).

Can you elaborate your doubts a bit more?



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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by pscott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Fri, 2007-11-16 at 16:50 +0000, Caroline Maynard wrote:
> Paul Scott wrote:
> Paul, not sure where you're coming from here - I think this really
> should work. There's no issue from the PHP point of view; this stuff is
> documented under the "Variable variables" section of the manual
> (http://php.net/manual/en/language.variables.variable.php), and the syntax
>
>     $my_object->{'weird-characters-here'} = "some text";
>
> is perfectly respectable. And Simon has pointed us at the relevant

I think that the spirit of my original post has kind of been lost now.
All that I am saying is that just because it *can* be done, does not
necessarily mean that it *should* be done.

At best, OP's case is a fringe case, and *probably* will cause more harm
than good in his application further down the line. If those cases are
not allowed (like Tuscanny) then, it is easier for OP to change one
variable now, than have a huge broken debugging nightmare later on. I
drew the example of SQL99 standards as I am well aware of the alarming
rate at which junior developers name date fields `date` in MySQL for
instance - perfectly legal according to MySQL, but a recipe for disaster
later on.

--Paul


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


All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by Simon Laws :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On 16 Nov, 18:07, Paul Scott <psc...@...> wrote:

> On Fri, 2007-11-16 at 16:50 +0000, Caroline Maynard wrote:
> > Paul Scott wrote:
> > Paul, not sure where you're coming from here - I think this really
> > should work. There's no issue from the PHP point of view; this stuff is
> > documented under the "Variable variables" section of the manual
> > (http://php.net/manual/en/language.variables.variable.php), and the syntax
>
> >     $my_object->{'weird-characters-here'} = "some text";
>
> > is perfectly respectable. And Simon has pointed us at the relevant
>
> I think that the spirit of my original post has kind of been lost now.
> All that I am saying is that just because it *can* be done, does not
> necessarily mean that it *should* be done.
>
> At best, OP's case is a fringe case, and *probably* will cause more harm
> than good in his application further down the line. If those cases are
> not allowed (like Tuscanny) then, it is easier for OP to change one
> variable now, than have a huge broken debugging nightmare later on. I
> drew the example of SQL99 standards as I am well aware of the alarming
> rate at which junior developers name date fields `date` in MySQL for
> instance - perfectly legal according to MySQL, but a recipe for disaster
> later on.
>
> --Paul
>
> All Email originating from UWC is covered by disclaimerhttp://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
I do see what you're saying Paul and we do have to be careful in cases
like these. I think if we were stepping outside of the various
specifications we would be on very dodgy ground. It's a balance
between supporting the schema that people already have (they most
likely use our technology if they have to change their schema to use
it) and not making it too easy for people to store up problems for
themselves as you say. Now we have a bug report for this I'll raise
one in Tuscany and see what the SDO community say. They may come back
with the same concerns that you have.

Regards

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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by monxton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


simonslaws@... wrote:

> I do see what you're saying Paul and we do have to be careful in cases
> like these. I think if we were stepping outside of the various
> specifications we would be on very dodgy ground. It's a balance
> between supporting the schema that people already have (they most
> likely use our technology if they have to change their schema to use

they most likely >won't< use our technology .. ?

> it) and not making it too easy for people to store up problems for
> themselves as you say. Now we have a bug report for this I'll raise
> one in Tuscany and see what the SDO community say. They may come back
> with the same concerns that you have.

The OP has some xml which validates against a schema, and which the XML
DAS consumes without a murmur but then Tuscany throws a confusing
exception when he tries to reference an element using valid PHP syntax,
which works for simplexml, dom and so on. This doesn't seem good enough
to me, and if we can't do any more because of Tuscany limitations, we
should at least provide an explanatory message documenting the
restriction - fortunately he worked out the cause of the problem for
himself.

I raised this on the Tuscany list
(http://thread.gmane.org/gmane.comp.apache.webservices.tuscany.devel/25795),
and Pete is having a think about the implications.


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


Re: How can I access a property containing a hyphen (i.e. "portfolio-id")

by monxton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Caroline Maynard wrote:

> I raised this on the Tuscany list
> (http://thread.gmane.org/gmane.comp.apache.webservices.tuscany.devel/25795),
> and Pete is having a think about the implications.

Tuscany have accepted my patch, so I've now checked it into our FULMAR
branch, and it will be in the next release.


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

LightInTheBox - Buy quality products at wholesale price