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

xml:id or xml:lang attributes handling #1221

Closed
amaccis opened this issue Jun 28, 2020 · 3 comments
Closed

xml:id or xml:lang attributes handling #1221

amaccis opened this issue Jun 28, 2020 · 3 comments

Comments

@amaccis
Copy link

amaccis commented Jun 28, 2020

Q A
Bug report? no
Feature request? IDK
BC Break report? no
RFC? no

Hi.
I don't know if JMS already has the feature I'm looking for, and stackoverflow too (e.g. https://stackoverflow.com/questions/24389574/jms-serializer-to-read-xmllang-attribute) does not answer.
I mean, is there a way to handle xml:id or xml:lang attributes? I can't use XmlNamespace with attributes so I can't find the proper way to solve my problem.
Thanks!
A.

@goetas
Copy link
Collaborator

goetas commented Jun 29, 2020

I think that here should be used \JMS\Serializer\Annotation\XmlMap, but the ability to define a custom namespace is not yet defined.

It would be a nice feature to have... are you interested in working on it?

@amaccis
Copy link
Author

amaccis commented Jun 29, 2020

Hi @goetas. I'll take a look.

@amaccis
Copy link
Author

amaccis commented Jul 11, 2020

Hi @goetas, I was taking a look to the code, in order to add the feature I need, and I realized that actually JMS already handles namespaces for attributes too. So I've probably put it badly when I asked for.
I solved it easily.

I had a tag like that
<tag xml:lang="lang">data</tag>

and I only needed to register the namespace with its prefix and use it

/**
 * @XmlNamespace(uri="http://www.w3.org/XML/1998/namespace", prefix="xml")
 */
class Tag
{
    /**
     * @var string
     * @Type("string")
     * @XmlAttribute(namespace="http://www.w3.org/XML/1998/namespace")
     * @SerializedName("lang")
     */
    private string $lang;

@amaccis amaccis closed this as completed Jul 11, 2020
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

2 participants