Hi.
Could anybody help? I don't know, what XPath I should use to get the value of a node. Here are my XML and XSL source:
Contacts.xml
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="alldata.xsl"?>
<contacts>
<contact id="b">
<name>Nick</name>
<age>26</age>
<city>Budapest</city>
</contact>
<contact id="u">
<name>Peter</name>
<age>28</age>
<city>London</city>
</contact>
</contacts>
alldata.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="//contact"/>
</body>
</html>
</xsl:template>
<xsl:template match="contact">
<div>
<xsl:element name="??????">
<xsl:if match=".[@id='b']">
<xsl:attribute name="style">color:red</xsl:attribute>
</xsl:if>
<xsl:value-of select="name"/><br/>
<xsl:value-of select="age"/><br/>
<xsl:value-of select="city"/>
</xsl:element>
</div>
</xsl:template>
</xsl:stylesheet>
Question: I'd like to put the value of id attribute of contact node as element( <b> or <u>). What XPath do I use?
regards, Kirilla
Could anybody help? I don't know, what XPath I should use to get the value of a node. Here are my XML and XSL source:
Contacts.xml
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="alldata.xsl"?>
<contacts>
<contact id="b">
<name>Nick</name>
<age>26</age>
<city>Budapest</city>
</contact>
<contact id="u">
<name>Peter</name>
<age>28</age>
<city>London</city>
</contact>
</contacts>
alldata.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="//contact"/>
</body>
</html>
</xsl:template>
<xsl:template match="contact">
<div>
<xsl:element name="??????">
<xsl:if match=".[@id='b']">
<xsl:attribute name="style">color:red</xsl:attribute>
</xsl:if>
<xsl:value-of select="name"/><br/>
<xsl:value-of select="age"/><br/>
<xsl:value-of select="city"/>
</xsl:element>
</div>
</xsl:template>
</xsl:stylesheet>
Question: I'd like to put the value of id attribute of contact node as element( <b> or <u>). What XPath do I use?
regards, Kirilla