Subject: [xsl] Problem using Muenchian method (apply-templates or key) with MSXM L 3.0 & 4.0 From: "Saldate, DanielX" <danielx.saldate@xxxxxxxxx> Date: Mon, 20 May 2002 08:36:18 -0700 |
Hello All, I've run into an interesting problem with MSXML 3.0 SP2 and 4.0 SP1. This seems to be related to invoking either of these parsers from code, but I'm not absolutely sure yet. I have an XML data island embedded into a web page that looks somewhat like the XML pasted below. I am sending this to a code fragment that invokes an XSL transform using the Muenchian method to group each of the Products by Category, and output the result into an HTML page. However, when I invoke the transform, only the root template takes effect. Using apply-templates within the root has no effect, and even explicitly calling the additional template by name produces only an empty HTML product table result. The really odd thing is that when I perform this transformation simply using the browser (IE 5.5 using MSXML 3), it works fine. All grouping is performed, and all results are correctly formed into HTML. I thought perhaps this was simply a problem of calling the wrong XML Parser from my code, so I also tried explicitly invoking the correct version using both the MSXML2.DOMDocument.4.0 and MSXML2.DOMDocument.3.0 version-specific ProgID's, but still the same result. Have I uncovered a bug in MSXML, or is something else wrong? I've posted sample code, XML, and my XSLT, which when invoke from an ASP page or COM object, consistently fails to transform the XML. Any help would be greatly appreciated. ---------------------------------------------------------------------------- ----------------------------------------------------------------- VBScript Code: ---------------------------------------------------------------------------- ----------------------------------------------------------------- Dim oDataXML, objStyleSheet, sTransformResult Set oDataXML = Server.CreateObject("MSXML2.DOMDocument.4.0") oDataXML.async = False oDataXML.Load Request Set objStyleSheet = Server.CreateObject("MSXML2.DOMDocument.4.0") objStyleSheet.async = False objStyleSheet.Load "http://" & _ server.URLPathEncode (Request.ServerVariables.Item("HTTP_HOST")) & "/" & _ MSCSAppFrameWork.VirtualDirectory & "/reports/ExhibitC4.xsl" sTransformResult = oDataXML.transformNode(objStyleSheet) Response.Write sTransformResult ---------------------------------------------------------------------------- ----------------------------------------------------------------- XML Sample: ---------------------------------------------------------------------------- ----------------------------------------------------------------- <XML ID="XMLData"> <ORDER> <Items> <Product> <ItemNumber>1</ItemNumber> <EffectiveDate>5/16/2002</EffectiveDate> <StopDate>5/16/2003</StopDate> <Action>Add</Action> <Category>AppChoice Managed Hosting Service - Web</Category> <Comment></Comment> <SKU>001-11-11111</SKU> <Name>Product 1</Name> <Desc>Long Description</Desc> <SalesDesc>N/A</SalesDesc> <FeeType>Monthly Fee</FeeType> <Qty>2</Qty> <Class>A</Class> <Discount>15.00%</Discount> <UnitFee>$1.00</UnitFee> <ExtendedPrice>$2.00</ExtendedPrice> <FeeMetric>N/A</FeeMetric> </Product> <Product> <ItemNumber>2</ItemNumber> <EffectiveDate>5/16/2002</EffectiveDate> <StopDate>5/16/2003</StopDate> <Action>Add</Action> <Category>AppChoice Managed Hosting Service - Database</Category> <Comment></Comment> <SKU>001-11-22222</SKU> <Name>Product 2</Name> <Desc>Long Description</Desc> <SalesDesc>N/A</SalesDesc> <FeeType>Setup Fee</FeeType> <Qty>1</Qty> <Class>A</Class> <Discount>15.00%</Discount> <UnitFee>$1.00</UnitFee> <ExtendedPrice>$1.00</ExtendedPrice> <FeeMetric>N/A</FeeMetric> </Product> <Product> <ItemNumber>3</ItemNumber> <EffectiveDate>5/16/2002</EffectiveDate> <StopDate>5/16/2003</StopDate> <Action>Add</Action> <Category>Managed Colocation Services</Category> <Comment></Comment> <SKU>001-11-00000</SKU> <Name>Product 3</Name> <Desc>Long Description</Desc> <SalesDesc>N/A</SalesDesc> <FeeType>Setup Fee</FeeType> <Qty>1</Qty> <Class>A</Class> <Discount>15.00%</Discount> <UnitFee>$1.00</UnitFee> <ExtendedPrice>$1.00</ExtendedPrice> <FeeMetric>N/A</FeeMetric> </Product> </Items> </ORDER> </XML> ---------------------------------------------------------------------------- ----------------------------------------------------------------- XSLT Sample: ---------------------------------------------------------------------------- ----------------------------------------------------------------- <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:key match="/XML/ORDER/Items/Product" use="Category" name="categories"/> <xsl:template match="/"> <html> <body> <xsl:apply-templates select="XML/ORDER/Items" /> </body> </html> </xsl:template> <xsl:template match="XML/ORDER/Items"> <xsl:apply-templates select="Product[generate-id(.) = generate-id(key('categories', Category)[1])]" /> </xsl:template> <xsl:template match="Product"> <xsl:text> - BEGIN </xsl:text><xsl:value-of select="./Category"/><xsl:text> : </xsl:text> <xsl:for-each select="key('categories',./Category)"> <xsl:value-of select="./SKU"/><xsl:text> , </xsl:text> </xsl:for-each> <xsl:value-of select="./Category"/><xsl:text> : </xsl:text><xsl:text> - END </xsl:text> </xsl:template> </xsl:stylesheet> Thanks in Advance, Jeremy Saldate, IOSE, Intel Corporation XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Second try: Search and re, Andrew Welch | Thread | Re: [xsl] Problem using Muenchian m, David Carlisle |
RE: [xsl] Second try: Search and re, Andrew Welch | Date | RE: [xsl] Second try: Search and re, Andrew Welch |
Month |