I am currently doing XML and XSLT and I have a question
I have done everything and validates fine but does not give me the right answer. One solution that worked fine was using CDATA but I want to use the xmlns=”http://www.w3.org/xhtml.
here is my relevant code
XML Schema
<xs:element name="bb">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any namespace="http://www.w3.org/1999/xhtml"
minOccurs="0"
maxOccurs="unbounded"
processContents="skip"/>
</xs:sequence>
</xs:complexType>
</xs:element>
XSLT
<xsl:template match="xsi:bb">
<div style="font-family:calibri;font-size:16">
<span style="color:#000">
Babo is:
</span>
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>
XML
<bb>
<li xmlns="http://www.w3.org/1999/xhtml">
hoby
</li>
<li xmlns="http://www.w3.org/1999/xhtml">
the best
</li>
</bb>
According to my theory it should return (when I convert XML to HTML)
but it is just returning hoby the best.
Why?
I think you need apply templates on li elements. xsl:value-of run for a subtree will read and concatenate all text nodes. AFAIR (may be wrong – you may want to double check this) disable output escaping is used for the content of the text node and not for elements text nodes belong too. The reason is that the li elements (in your case) are seperate elements in the tree and are internally treated as such and not as elements. If you want just to copy li elements as is you can just use something like this:
(or if you want to copy all elements:
)