467,895 Members | 1,472 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,895 developers. It's quick & easy.

Problem with XSLTransform Class in .NET

Hi,

Following template matches correctly in MSXML4 but NOT with .Net XSL
translator:

<xsl:template
match="//input[@value='go'][preceding-sibling::a[position()=1][contains(img/@src,'cancel')]]">

<--Do Some operation>
</xsl:template>

Code I wrote to translate the XML:
// Create an XPathNavigator to use for the transform.
XPathDocument mydata = new XPathDocument(xmlfile);
XPathNavigator nav = mydata.CreateNavigator();

// Transform the file.
XslTransform xslt = new XslTransform();
xslt.Load(xslfile);
XmlTextWriter writer = new XmlTextWriter(outputfile, null);

xslt.Transform(mydata,null,writer,null);
writer.Close();

I'm unable to figure out the problem. If anyone knows the solution, do let
me know.
I have also attached the input XML and XSL.

Thanks,
Animesh

Input XML:

<?xml version="1.0"?>
<html><body>
<table><tbody><tr><td>
<a href="http://www.hotmail.com" onmouseover="" onmouseout="">
<img src="http://myprod.concureworkplace.com/ewp/Images/entrycancel.gif"
alt="Cancel" border="0" title="Cancel"/></a>
<input type="submit" name="onclick" value="go"/>
</td></tr></tbody></table></body></html>

Input XSl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" method="xml"/>

<xsl:template match="//a[img[contains(@src,'cancel')]]" priority="1"/>
<xsl:template
match="input[@value='go'][preceding-sibling::a[position()=1][contains(img/@src,'cancel')]]">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="type">Submit</xsl:attribute>
<xsl:attribute name="value">Cancel</xsl:attribute>
<xsl:apply-templates select="*|text()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="*|text()|@*">
<xsl:copy>
<xsl:apply-templates select="*|text()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Jul 21 '05 #1
  • viewed: 1218
Share:
1 Reply

"Animesh Sharma" <Animesh Sh****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Hi,

Following template matches correctly in MSXML4 but NOT with .Net XSL
translator:


You may want to post this to microsoft.public.dotnet.xml instead, thats
where all the XML wonks hang out.
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by John Lehmann | last post: by
2 posts views Thread by Graham Pengelly | last post: by
8 posts views Thread by Demon News | last post: by
7 posts views Thread by Harolds | last post: by
1 post views Thread by avnrao | last post: by
1 post views Thread by manlio | last post: by
1 post views Thread by Lasse Edsvik | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.