使用以下 XML,我需要选择家庭地址(如果存在),如果不存在则选择工作地址。所以我试图找到从 wd:Address_Line_Data/wd:Usage/wd:Type_Data/wd:Type_Reference/@wd 的起点选择 wd:Address_Line_Data[@wd:Descriptor="Address_Line_1"] 值的语法:描述符="首页"
这是 XML:
<wd:Contact_Data>
<wd:Address_Data>
<wd:Address_Line_Data wd:Descriptor="Address Line 1">
<wd:Usage_Data>
<wd:Type_Data>
<wd:Type_Reference wd:Descriptor="Work">
</wd:Type_Reference>
</wd:Type_Data>
</wd:Usage_Data>
</wd:Address_Data>
<wd:Address_Data>
<wd:Usage_Data>
<wd:Type_Data>
<wd:Type_Reference wd:Descriptor="Home">
</wd:Type_Reference>
</wd:Type_Data>
</wd:Usage_Data>
</wd:Address_Data>
</wd:Contact_Data>
我对 XSTL 很陌生,我尝试了以下三个表达式,所有这些表达式都没有任何作用。我正在使用 xml 1.0。有什么建议么?提前致谢!
<xsl:value-of select="wd:Worker_Data/wd:Personal_Data/wd:Contact_Data/wd:Address_Data/wd:Usage_Data/wd:Type_Data/wd:Type_Reference[@wd:Descriptor='Home']/ancestor::wd:Address_Data/wd:Address_Line_Data[@wd:Descriptor='Address_Line_1']"/>
<xsl:value-of select="wd:Worker_Data/wd:Personal_Data/wd:Contact_Data/wd:Address_Data/wd:Usage_Data/wd:Type_Data/wd:Type_Reference[@wd:Descriptor='Home'][ancestor::wd:Address_Data[wd:Address_Line_Data[@wd:Descriptor='Address_Line_1']]]"/>
<xsl:value-of select="wd:Worker_Data/wd:Personal_Data/wd:Contact_Data/wd:Address_Data/wd:Usage_Data/wd:Type_Data/wd:Type_Reference[@wd:Descriptor='Home']/ancestor::wd:Usage_Data/preceding-sibling::wd:Address_Line_Data[@wd:Descriptor='Address_Line_1']"/>