Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: decoding a>b>c decoration syntax should support namespaces #37133

Open
wz2b opened this issue Feb 8, 2020 · 1 comment
Open
Labels
ExpertNeeded NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@wz2b
Copy link

wz2b commented Feb 8, 2020

What version of Go are you using (go version)?

$ go version
go version 1.13.5 windows/amd64

Does this issue reproduce with the latest release?

Yes, behaves same on 1.13.7

What operating system and processor architecture are you using (go env)?

Windows/amd64 but this is repeatable at least on linux

go env Output
$ go env

What did you do?

I set up a struct with

I set up this set of structures

type myGetValueResponseEnvelope struct {
	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
	Body    myGetValueResponseBody
}
type myGetValueResponseBody struct {
	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
	Value   string   `xml:"getValueResponse>getValueReturn"`
}

to decode this XML:

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <getValueResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <getValueReturn xsi:type="xsd:string">69.1</getValueReturn>
      </getValueResponse>
   </soapenv:Body>
</soapenv:Envelope>

but I wanted to eliminate the second object by using a>b>c syntax. Note though that the soapenv namespace is as far as Body but not farther. So I attempted this

type myGetValueResponseEnvelope struct {
	XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
	Value string `xml:"http//schemas.xmlsoap.org/soap/envelope Envelope>getValueResponse>getValueReturn"`
}

but it doesn't SEEM with a>b>c syntax that there's any way to have namespaces in all or (in my case) part of the xpath.

I can just eliminate the namespace requirement on Body and it actually decodes just fine, so this isn't an urgent issue at the moment, but some day I may want to be more selective. Regardless it seems the answer would be to split on > then ' ' then process it as usual.

@odeke-em odeke-em changed the title decoding xml a>b>c decoration syntax should support namespaces encoding/xml: decoding a>b>c decoration syntax should support namespaces Feb 8, 2020
@odeke-em
Copy link
Member

odeke-em commented Feb 8, 2020

Thank you for filing this issue @wz2b and welcome to the Go project!

I am not an XML expert but I shall kindly ping @mvdan @rogpeppe @nigeltao.

@odeke-em odeke-em added ExpertNeeded NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 8, 2020
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExpertNeeded NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants