How can I get attribute values to not get converted from ' to '
or & to & or < to > ?
The whole point about < is that it means the same thing as > (not
always in element content if the preceding two characters were ]] but in
attribute values they always mean the same thing.
If you go
<foo bar=">"/><foo bar=">"/> Then XSLT will see identical input from
the two forms, and it may use either form on output. It has no way of
knowing which form was used, any more than it has of knowing whther yiou
used " or ' to surround the attribute value.
The problem is I am importing this stuff into a DB and I need to keep
all those ' and other escapings..
If that import mechanism is not aware of XML conventions so is broken by
XML quoting syntax they you will have to use the text output method of
xslt and write out the literal tags that you want rather than allowing
XSLT to linearise an element tree for you. But you lose most of the
benefits of xslt doing that.
so
<xsl:output method="text"/>
....
<xsl:template match="xyz">
<foo bar="<xsl:value-of select="@CATEGORY"/>" ..../>
....
Also, is there a way to do something like this
<![CDATA[
<xsl:value-of select="@CATEGORY" />
]]>
Well you can do exactly that, as you observe, but then the
<xsl:value-o
is taken as character data not element markup.
The problem with this is it gives me
<xsl:value-of select="@CATEGORY" />
where I want
Men's Clothing
As I say above If you mean that you had an input string of
Men's Clothing
and you need it to come out as
Men's Clothing
and not as
Men's Clothing
then basically you can't use XSLT as the XML parser will report these
two things as the same. So there is no way XSLT can preserve the difference.
David