Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 284453 - Last Review: June 4, 2003 - Revision: 2.0
BUG: XML Context Method Can Traverse Out of Xsl:template Element
This article was previously published under Q284453
On This Page
SYMPTOMS
When you use the
context method of the "http://www.w3.org/TR/WD-xsl" namespace, it is possible to use a negative value for the index parameter from an
xsl:template element, effectively navigating the context out of the template. It should not be possible to do this because the template can be called from more than one location, which means that the value of
context(-n) changes depending on how the template is called.
RESOLUTION
This problem is discussed here for reference purposes only, because the
context method has been superceded by the
current method of the "http://www.w3.org/1999/XSL/Transform" namespace.
Use the
current method and its corresponding namespace instead of the
context method.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
MORE INFORMATION
Steps to Reproduce Behavior
- Insert the following code into a new text document, and save the file as repro.xml:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="repro.xsl" ?>
<Data>
<StudentBody>
<Student name="Jon Burchel">
</Student>
</StudentBody>
</Data>
- Insert the following text into another new document, and save the file as repro.xsl in the same location as the XML file you just created:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="http://support.microsoft.com">
<HTML>
<BODY>
<xsl:apply-templates select = "Data/StudentBody/*" />
</BODY>
</HTML>
</xsl:template>
<xsl:template match="Student">
<!-- context() is OK -->
<LI><xsl:value-of select = "@name" /></LI><BR/>
<xsl:if test="context()[$not$ end()]"><BR/></xsl:if>
<!-- context(-2) should not be possible -->
<B>This should not work!!!</B><BR/>
<LI><xsl:value-of select = "@name" /></LI><BR/>
<xsl:if test="context(-2)[$not$ end()]"><BR/></xsl:if>
</xsl:template>
</xsl:stylesheet>
- Browse to repro.xml by using Internet Explorer (IE). The template should not be able to query the negative context, but it does so successfully.
APPLIES TO
- Microsoft XML Parser 2.0
- Microsoft XML Parser 2.5
- Microsoft XML Parser 2.6
- Microsoft XML Parser 3.0
- Microsoft Internet Explorer 4.0 128-Bit Edition
- Microsoft Internet Explorer 4.01 Service Pack 2
- Microsoft Internet Explorer 4.01 Service Pack 1
- Microsoft Internet Explorer 5.0
- Microsoft Internet Explorer 5.01
- Microsoft Internet Explorer (Programming) 5.01 SP1
- Microsoft Internet Explorer 5.5
| kbbug kbpending kbmsxmlnosweep KB284453 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please