Problem with XSLTransform Class in .NET

G

Guest

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:blush:utput 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>
 
D

Daniel O'Connell [C# MVP]

Animesh Sharma said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top