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">
<xslutput 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>
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">
<xslutput 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>