xml - xsl to get the element node value and attribute of parent node -
i'm trying place in text file following:
<skos:concept rdf:about="http://aims.fao.org/aos/agrovoc/c_26321"> <skos:preflabel xml:lang="fa">آبیس ماریزیای</skos:preflabel> <skos:preflabel xml:lang="zh">大白叶冷杉</skos:preflabel> <skos:preflabel xml:lang="tr">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="th">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="sk">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="ru">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="pt">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="hi">एबीस मैरीइसी</skos:preflabel> <skos:preflabel xml:lang="pl">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="lo">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="it">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="hu">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="de">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="cs">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="fr">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="es">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="en">abies mariesii</skos:preflabel> <skos:preflabel xml:lang="ja">オオシラビソ、アオモリトドマツ</skos:preflabel> <skos:preflabel xml:lang="ar">شوح ماريزي</skos:preflabel> <skos:broader rdf:resource="http://aims.fao.org/aos/agrovoc/c_10"/>
i want value of skos:preflabel xml:lang="en" , attribute value of skos:concept rdf:about, transformed below:
=301 \\$abroader$babies mariesii$c=301 \\$abroader$babies mariesii
i have below xslt script can't seem transform correctly:
<?xml version="1.0" encoding="utf-8"?> .... <xsl:apply-templates select="skos:concept" /> <xsl:text> </xsl:text> .... <xsl:template match="skos:concept"> <xsl:if test="skos:broader"> <xsl:for-each select="skos:preflabel|skos:concept" /> <xsl:text>=301 \\$abroader$b</xsl:text><xsl:value-of select="skos:preflabel[@xml:lang='en']" /><xsl:text>$c</xsl:text><xsl:value-of select="skos:concept[rdf:about]" /> <xsl:text> </xsl:text> </xsl:if> </xsl:template>
tia!
(*for archiving purposes) following solved problem:
<xsl:template match="skos:concept"> <xsl:if test="skos:broader"> <xsl:for-each select="skos:preflabel|skos:concept" /> <xsl:text>=301 \\$abroader$b</xsl:text><xsl:value-of select="skos:preflabel[@xml:lang='en']" /><xsl:text>$c</xsl:text><xsl:value-of select="./@rdf:about" /> <xsl:text> </xsl:text> </xsl:if>
it matter of adding 1 line code. , offshoot of reading particular stackoverflow question: getting parent node attributes in xsl
Comments
Post a Comment