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

Possible to prefix the root element while serializing? #5

Open
fredericomartini opened this issue Nov 12, 2016 · 10 comments
Open

Possible to prefix the root element while serializing? #5

fredericomartini opened this issue Nov 12, 2016 · 10 comments

Comments

@fredericomartini
Copy link

fredericomartini commented Nov 12, 2016

While generating metadata files is possible to set namespace prefix to the root element?
e.g:

myXmlElement:
xml_root_name: "ds1:foobar"
xml_root_namespace: "http://www.example"

will turn serialized:

<?xml version="1.0" encoding="UTF-8"?>
<ds1:foobar xmlns:ds1="http://www.example">
</ds1:foobar>

@goetas
Copy link
Member

goetas commented Nov 12, 2016

Hi, this is not possible at the moment. I have solved it adding the prefix
in the root name.

But it will be an interesting feature for the jms serializer, PR are
welcome

On 12 Nov 2016 1:57 pm, "Frederico Martini" notifications@github.com
wrote:

While generating metadata files is possible to set namespace prefix to the
root element?
e.g:
myXmlElement:
xml_root_name: "ds1:foobar"
xml_root_namespace: "http://www.example"

will turn serialized:

<ds1:foobar xmlns:ds1="http://www.example">
/ds1:foobar


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#5, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAvaJ3SyrZ2H_SdfWWFb8hu0nTklxNCrks5q9beggaJpZM4KwaVM
.

@goetas
Copy link
Member

goetas commented Nov 12, 2016

Reading better your message, do not understand the problem. What you have suggested in your code snippet is exactly how is implemented now

@fredericomartini
Copy link
Author

I can only set prefix name to xml_root_name in .yml files already generated, not based on config.yml
e.g.
I have the xsd above:
https://gist.github.com/fredericomartini/481a4fd7774cde6e93b85cdb042604c8
When generate my metadata I would like my namespace seems like: xmlns:tipos="http://www.ginfes.com.br/tipos_v03.xsd"
How as wrote on the 1th.
And what is generated is:
https://gist.github.com/fredericomartini/c2a25073750766c65ecb5bd99f3f9329

Default namespace generate is: xmlns:ns-13a1074f="http://www.ginfes.com.br/tipos_v03.xsd"

Better to understand now?

Thanks @goetas

@goetas
Copy link
Member

goetas commented Nov 14, 2016

ah, i see.
this is a know limitation of the jms serializer, but schmittjoh/serializer#644 is a fix for it.

planned to be resolved in 1.5 or 1.6 version of jms serializer

@steve-rhodes
Copy link

I have the same problem. I still don't know how to set the root_name. And I don't know how schmittjoh/serializer#644 is solving this?

All I get is a random generated string. For example: xml_root_name: 'ns-0a7b0155:ManifestMessage'
Where is ns-0a7b0155: coming from? How can I set it myself?

thanks

@goetas
Copy link
Member

goetas commented Jan 16, 2018

any reason to have a specific prefix? for xml-sematics prefix should be almost irrelevant

@steve-rhodes
Copy link

Unfortunately our delivery house for Spotify rejected our xml's and said the root_name wasn't set as they need.

I understand that a quick fix would be to change the .yml manually, right?

I also need this added xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance”
How can I do this?

The .yml looks like this:

App\Ci\NewReleaseMessage:
    xml_root_name: 'ns-61e1d5b4:NewReleaseMessage'
    xml_root_namespace: 'http://ddex.net/xml/2010/ern-main/32'

generating this:

<?xml version="1.0" encoding="UTF-8"?>
<ns-0a7b0155:ManifestMessage xmlns:ns-0a7b0155="http://ddex.net/xml/2011/echo/11" MessageVersionId="2010/ern-main/312">

But I need:

<echo:ManifestMessage xmlns:echo="http://ddex.net/xml/2011/echo/11"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xsi:schemaLocation="http://ddex.net/xml/2011/echo/11 http://ddex.net/xml/2011/echo/11/echo.xsd"
                      MessageVersionId="2010/ern-main/312">

Any idea? Thanks again!

@goetas
Copy link
Member

goetas commented Jan 16, 2018

$data["xml_root_name"] = "ns-" . substr(sha1($data["xml_root_namespace"]), 0, 8) . ":" . $data["xml_root_name"];
is the part of code to edit! PR are welcome!

@goetas goetas reopened this Jan 16, 2018
@goetas goetas removed the question label Jan 16, 2018
@pribeirojtm
Copy link

Hello, is this issue still occuring? I'm having the same problem as reported in this post.
Do we still have to hack xsd2php/src/Jms/YamlConverter.php:150 ?

$data["xml_root_name"] = "ns-" . substr(sha1($data["xml_root_namespace"]), 0, 8) . ":" . $data["xml_root_name"];

Or do we have now something to give what we want?

Thanks
?

@goetas
Copy link
Member

goetas commented Apr 3, 2020

This the part of code to edit! PR are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants