惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

博客园 - DataFlow

word break 在不同浏览器中的表现 系统架构 创造HTTPS的是个神 为Chrome开发插件提高工作效率 Javascript 控制style 小结 xeam Build Definition Extension uninstall 卸载 Wcf客户端配置里Endpoint的Name属性无效 屏蔽电信流氓弹出广告 正则替换中的一个Bug SQL server 性能相关 SQL Express 相关 时间格式 输出一个在没有.Net 环境的机器也可以跑得安装包 再谈性能力 SCOM Configuration NumSamples and Absolute XML中的时间 decimal.Round 的区别 Dos中常用的命令 反序列化怪现象,数组无父
svcutil 生成代理类时的问题
DataFlow · 2014-12-26 · via 博客园 - DataFlow

如果有这个的xsd, group内嵌choice的结构:

<xs:complexType name="CreateType">
        <xs:sequence>
               <xs:group ref="NameChoicesGroup" />
               <xs:element name="Info" type="InfoType" />
        </xs:sequence>
</xs:complexType>

<xs:group name="NameChoicesGroup">
        <xs:choice>
                <xs:element name="NameID" type="IDType"/>
                <xs:element name="Name" type="xs:string"/>
        </xs:choice>
</xs:group>

使用svcutil 生成后的结果是:

public class CreateType

{

  int NameID

      string Name

}

因为是choice 类型,这个结果显然不能表示choice的特点,bug?

解决问题:

生成前,使用xslt 把所有的group替换成实际的内容, 生成结果:

public class CreateType

{

    [System.Xml.Serialization.XmlElementAttribute("NameID", typeof(uint), Order = 0)]

    [System.Xml.Serialization.XmlElementAttribute("Name", typeof(string), Order = 0)]

    [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")] 

     object Name {...}

}

xslt:

<xsl:stylesheetversion="1.0" xmlns:xsl=http://www.w3.org/1999/XSL/Transform" xmlns:xs=http://www.w3.org/2001/XMLSchema>

<xsl:outputmethod="xml"indent="yes"/>

<xsl:keyname="Groups"match="xs:group[@name='NameChoicesGroup']"use="@name"/>

 <xsl:templatematch="xs:group[@ref='NameChoicesGroup']">

<xsl:comment> 

Begin

<xsl:value-ofselect="@ref"/>

</xsl:comment><xsl:variablename="Temp"select="key('Groups', 'NameChoicesGroup')"/>

<xsl:copy-ofselect="$Temp/xs:choice"/>

<xsl:comment> 

 End

<xsl:value-ofselect="@ref"/>

</xsl:comment>

</xsl:template>

<xsl:templatematch="@*|node()">

<xsl:copy>

<xsl:apply-templatesselect="@*|node()" />

</xsl:copy>

</xsl:template>

</xsl:stylesheet>