I have an xml document which has the contents :
<series>
<dataset id="dataset_1" name="Client - number unplanned">
<data id="dataset_1_1" value="1"/>
<data id="dataset_1_2" value="2"/>
<data id="dataset_1_3" value="3"/>
<data id="dataset_1_4" value="4"/>
<data id="dataset_1_5" value="5"/>
<data id="dataset_1_6" value="6"/>
<data id="dataset_1_7" value="7"/>
<data id="dataset_1_8" value="8"/>
<data id="dataset_1_9" value="9"/>
<data id="dataset_1_10" value="10"/>
<data id="dataset_1_11" value="11"/>
<data id="dataset_1_12" value="12"/>
</dataset>
</series>
I need to create an XSL document that will be applied to the about XML doc
and give on line as
<Row firstattribute=" <dataset id="dataset_1" name="Client - number
unplanned"><data id="dataset_1_1" value="1"/>...</dataset>" />
What XSLT or xpath function do I need to extact the above code and insert it
into an attribute.
Sham.
sham wrote:
> I need to create an XSL document that will be applied to the about XML doc
> and give on line as
>
> <Row firstattribute=" <dataset id="dataset_1" name="Client - number
> unplanned"><data id="dataset_1_1" value="1"/>...</dataset>" />
That is not well-formed XML at all, '<' would need to be escaped as
'<' for instance, '"' as '"'.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
What we have is a client dataset (an in memory table) that works by giving
it some data in the format :
<ROW attr= "" etc ?>
This component handles the escaping. But I need to create an XSLT script
that will give us the row with the XML apart of the attribute. Can this be
done?
Sham.
"Martin Honnen" <maho...@yahoo.de> wrote in message
news:%23VbEg73...@TK2MSFTNGP05.phx.gbl...
sham wrote:
> This component handles the escaping. But I need to create an XSLT script
> that will give us the row with the XML apart of the attribute. Can this be
> done?
I am not sure I understand what you want to achieve. If you want XML to
be a part of an attribute value then you need to escape the XML e.g.
like this stylesheet does
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="dataset">
<Row>
<xsl:attribute name="firstattribute"><xsl:apply-templates
select="." mode="serialize" /></xsl:attribute>
</Row>
</xsl:template>
<xsl:template match="*" mode="serialize">
<xsl:text><</xsl:text>
<xsl:value-of select="name()" />
<xsl:apply-templates select="@*" mode="serialize" />
<xsl:text>></xsl:text>
<xsl:apply-templates mode="serialize" />
<xsl:text></</xsl:text>
<xsl:value-of select="name()" />
<xsl:text>></xsl:text>
</xsl:template>
<xsl:template match="@*" mode="serialize">
<xsl:text> </xsl:text>
<xsl:value-of select="concat(name(), '="', ., '"')" />
</xsl:template>
</xsl:stylesheet>
Applied to your XML sample the result is then
<Row firstattribute="<dataset id="dataset_1"
name="Client - number unplanned"><data
id="dataset_1_1" value="1"></data><data
id="dataset_1_2" value="2"></data><data
id="dataset_1_3" value="3"></data><data
id="dataset_1_4" value="4"></data><data
id="dataset_1_5" value="5"></data><data
id="dataset_1_6" value="6"></data><data
id="dataset_1_7" value="7"></data><data
id="dataset_1_8" value="8"></data><data
id="dataset_1_9" value="9"></data><data
id="dataset_1_10"
value="10"></data><data
id="dataset_1_11"
value="11"></data><data
id="dataset_1_12"
value="12"></data></dataset>"></Row>
Just what I needed. We are using a 3rd party component and we have to
construct the xml in a certain format.
Once again, thanks.
Sham.
"Martin Honnen" <maho...@yahoo.de> wrote in message
news:OGnDTX5b...@TK2MSFTNGP05.phx.gbl...
sham wrote:
> We are using a 3rd party component and we have to
> construct the xml in a certain format.
Out of curiosity, which component exactly is that that requires to put
the markup of XML nodes escaped into an attribute value?