Here's the code (well, an approximation of it - this is for a job, so I renamed tags whose names might cause issues, I also shortened the XML a bit) [CODE]<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fn="http://www.w3.org/2005/04/xpath-functions" xmlns:pgd="urn:FindingImport"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/ > <xsl:param name="filetoprocess"/> <xsl:template match="DOCUMENT"> <xsl:element name="RECORDS"> <xsl:apply-templates select="document($filetoprocess)/ pgd:IMPORT_FILE"/> </xsl:element> </xsl:template> <xsl:template match="pgd:IMPORT_FILE"> <xsl:apply-templates select="pgd:ASSET"/> </xsl:template> <xsl:template match="pgd:ASSET"> <xsl:apply-templates mode="PGD" select="pgd:TARGET"> <xsl:with-param name="item1" select="./pgd:asset_...@type='item1']"/ > <xsl:with-param name="item2"> <xsl:choose> <xsl:when test="count(./pgd:asset_...@type='Item2']) > 0"> <xsl:value-of select="./pgd:asset_...@type='Item2']"/> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="count(./pgd:asset_...@type='itemtwo']) > 0"> <xsl:value-of select="./pgd:asset_...@type='itemtwo']"/> </xsl:when> <xsl:otherwise><xsl:value-of select="./pgd:ASSET_ID [...@type='qbert']"/></xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:with-param> <xsl:with-param name="item3" select="./pgd:asset_...@type='item3']"/ > </xsl:apply-templates> </xsl:template> <xsl:template match="pgd:TARGET" mode="PGD"> <xsl:param name="item1" select="$item1"/> <xsl:param name="item2" select="$item2"/> <xsl:param name="item3" select="$item3"/> <xsl:choose> <xsl:when test="count(./pgd:carpediem) > 0"> <xsl:apply-templates select="pgd:chapter" mode="Siskel"> <xsl:with-param name="item2" select="$item1"/> <xsl:with-param name="item1" select="$item1"/> <xsl:with-param name="item3" select="$item3"/> <xsl:with-param name="item4" select="./pgd:Remus"/> <xsl:with-param name="dae" select="./pgd:Rome"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="pgd:chapter" mode="Ebert"> <xsl:with-param name="item2" select="$item2"/> <xsl:with-param name="item1" select="$item1"/> <xsl:with-param name="item3" select="$item3"/> <xsl:with-param name="item4" select="./pgd:Greece"/> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>[/CODE] and [CODE] XsltArgumentList xslArg = new XsltArgumentList(); string newfile = "C:\\XslProc\\testfiles"; string strReportPath = "C:\\XslProc\\testfiles\ \testfile.xml"; xslArg.AddParam("filetoprocess", "", newfile); XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load(@"C:\Documents and Settings\lilithsthrall\My Documents\Visual Studio 2005\Projects\engine\engine\Robust.xslt"); XPathDocument xpathdocument = new XPathDocument (strReportPath); //XPathDocument xpathdocument = new XPathDocument(@"C: \XslProc\testfiles"); string strPackagedFile = newfile + "\\Packaged\\new.xml"; XmlTextWriter writer = new XmlTextWriter(strPackagedFile, null); xslt.Transform(xpathdocument, xslArg, writer); writer.Close();[/CODE]
is throwing an error "the variable or parameter 'item1' is not defined or is out of scope". Note that this is being thrown in Visual Studio -before- the XSLT is applied to XML and -also- after the program has been started. On Apr 11, 4:35 am, Cerebrus <[email protected]> wrote: > IIRC, The .NET 2.0 XslCompiledTransform does not pass the params to > subsequent matches in the hierarchy, only to the first match, if > you're using a wide scoped <xsl:apply-templates /> instead of > providing it a specific nodeset to work on. To be more specific, I > think we'll need to see a (simplified version) of your XSLT and the > XML. > > On Apr 10, 9:53 pm,LilithsThrall<[email protected]> wrote: > > > > > I've got an XSLT stylesheet. It has many different calls to apply- > > templates. These apply-templates calls pass params to their related > > templates. > > Pretty garden variety really. > > But .NET 2.0 is throwing an error that the params are undefined or out > > of scope. > > Now, the stylesheet works correctly in XML Spy. So, I'm wondering if > > there is a known bug in .NET 2.0 XmlCompiledTransform/XPathDocument > > that causes it to have scoping problems for parameters passed via > > apply-templates? If so, is there a known work around or patch? I'm > > dealing with a -lot- of data, the last thing I want to do is rewrite > > the stylesheet as some sort of imperative programming hack.- Hide quoted > > text - > > - Show quoted text -
