Re: Editing XML



"Hans-Peter Diettrich" <DrDiettrich1@xxxxxxx> wrote in message
news:5d4eu7F32vbnhU3@xxxxxxxxxxxxxxxxxxxxx
Rob Kennedy wrote:

<xsl:template match="MSHelp:link">
<xsl:element name="a">
<xsl:copy-of select="@*"/>

How should this read, in order to translate the keywords="..." into a
href="html/...htm" attribute, dropping all other attributes?

To transform
<MSHelp:link keywords="***">click here</MSHelp:link>
into
<a href="html/***.htm">click here</a>,
something like

<xsl:template match="MSHelp:link">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>html/</xsl:text>
<xsl:value-of select="@keywords" />
<xsl:text>.htm</xsl:text>
</xsl:attribute>
<xsl:apply-templates select="*|text()" /> <!-- exclude @* -->
</xsl:element>
</xsl:template>

Not tested.


To perform the transformation, I used Ant, the Java build tool,
because that's the only way I know how to invoke XSL transformations.

You can download Saxon. Or Xalan. Or the MS XML SDK, which appears to
include the MSXSL utility.


Hmmm, a transformation should be made whenever my browser has to show a
help page. Unless there exists a simpler programmatic way of invoking
the script, I'll stick with cloning the nodes.

Put <?xml-style*** type="text/xsl" href="whatever.xslt" ?> near the top
of your XML documents. That should make the client run the transformation
'whatever.xslt' on the document. Meaning lots of things can still go
wrong.

Groetjes,
Maarten Wiltink


.