How to send Jaxb XmlAttribute data without java double quotes

前端 未结 1 1130
梦谈多话
梦谈多话 2021-01-29 04:06

So I have the following issue when trying to build an xml from java class using jaxb. My first tag needs to be like this :


So         


        
相关标签:
1条回答
  • 2021-01-29 04:24

    In XML applications the principle should be:

    (a) Receiving applications shouldn't care about the insignificant lexical detail of how the XML is written. (The best way of achieving this is to use a respectable XML parser to read the XML.)

    (b) Writing applications should be free to use whatever lexical conventions they find convenient. (Which means you can use any respectable serialization library to write the XML.)

    The choice of single or double quotes for attributes is one of these insignificant lexical details.

    We see a LOT of problems on StackOverflow caused by people not following these rules.

    You haven't explained WHY you need to generate single quotes. Perhaps the XML is being consumed by an application that doesn't follow rule (a). In that case you should fix it! If you can't fix it, then you are vastly increasing your costs, in fact, there's very little point in using XML at all.

    Sometimes when we ask this question we get the answer "because by client insists on it being that way". It's our job as professionals to educate our clients: they're paying the bills and it's irresponsible to spend their money on bad engineering even if that's what they said they wanted.

    0 讨论(0)
提交回复
热议问题