首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当同一级别的元素和属性具有相同的名称时,scalaxb会失败

当同一级别的元素和属性具有相同的名称时,scalaxb会失败
EN

Stack Overflow用户
提问于 2018-08-26 18:22:10
回答 1查看 130关注 0票数 0

我正在尝试使用sbt-scalaxbFixRepository.xsd生成绑定,但它不像SUBJ。

当然,作为最后的手段,我可以稍微修改一下模式,但是是否有一种方法可以调优sbt-scalaxb以理解原始文件?

sbt-scalaxb不喜欢的XSD片段是:

xml <xs:element name="component"> <xs:complexType> <xs:sequence> <xs:element ref="messageEntity" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attributeGroup ref="entityAttribGrp"/> <xs:attribute name="id" type="id_t" use="required"/> <xs:attribute name="name" type="xs:string" use="required"/> <xs:attribute name="type" type="ComponentType_t" use="required"/> <xs:attribute name="repeating" type="BOOL_t" use="optional"/> <xs:attribute name="category" type="xs:string" use="optional"/> <xs:attribute name="abbrName" type="xs:string" use="optional"/> <xs:attribute name="notReqXML" type="BOOL_t" use="optional"/> <!-- would like to force a description of the component --> </xs:complexType> </xs:element>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-26 21:50:25

我自己想出来了:scalaxbAttributePrefix设置为属性属性添加了一个前缀。

build.sbt

代码语言:javascript
复制
scalaxbAttributePrefix in (Compile, scalaxb) := Some("attr")

生成的FixRepository.scala

代码语言:javascript
复制
case class Fix(
    ...,
    components: ...fixrepo.Components,
    ...,
    attributes: Map[String, scalaxb.DataRecord[Any]] = Map()
) {
    ...
    lazy val attrComponents = attributes("@components").as[BOOL_t]
    ...
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52025304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档