php - JMS 序列化程序在根元素中设置自定义命名空间名称
问题描述
想象一下,我想xsi:schemaLocation
在根目录中有命名空间和属性:
<root xsi:schemaLocation="url">...</root>
如何在 Symfony 4 的 JMS/Serializer 中做到这一点?
我有这个类,我希望在序列化时在其根元素上具有此属性,请参阅类片段:
/**
* @XmlRoot("partner")
* @XmlNamespace(uri="http://www.w3.org/2001/XMLSchema-instance", prefix="xsi")
*/
class PartnerInfo implements RequestDtoInterface
{
仅供参考,我成功地@XmlNamespace
在类上使用注释来创建xmlns:xsi
属性。问题是使用@XmlNamespace
命名空间属性名称总是以xmlns
. 但我只想要xsi:schemaLocation
.
将它传递给序列化程序时,也许可以使用SerializationContext
对象和类来完成它?Metadata
但是我尝试使用它时没有成功...
解决方案
推荐阅读
- html - 如何显示加载到该部分的数据表中的密码
- java - Firebase 回收器适配器数据库异常
- javascript - 将 Html Css3 动画录制为视频
- c# - OpenQA.Selenium.WebDriverException: '无法在 http://localhost:60623/ 上启动驱动程序服务'
- c# - 在 C# 中禁用 AWS SDK for S3 中的分块传输编码
- android - 无法为 org.gradle.api.Project 类型的项目“:demo”获取未知属性“ANDROID_SUPPORT_VERSION”
- javascript - 使用伪元素工具提示单击时复制到剪贴板
- protractor - 为什么 sendKeys 在第二次迭代中不输入值
- reactjs - 地图没有显示
- python - Django按日期注释分组返回对象