Kirik Alexander
2005-10-09 21:17:28 UTC
Hello, All!
При попытке передать параметр в XSLT-файл возникает ошибка.
В aspx-файле:
<asp:Xml id="Xml1" runat="server" TransformSource="~\menu4.xslt"
DocumentSource="~\menu3.xml"></asp:Xml>
aspx.cs файл:
private void Page_Load(object sender, System.EventArgs e)
{
string ss="Page2";
string PathAp1 = Request.ApplicationPath;
string FileXML = PathAp1;
FileXML += "/Menu3.xml";
string FileXSL = PathAp1;
FileXSL += "/menu4.xslt";
Xml1.DocumentSource=FileXML;
Xml1.TransformSource = FileXSL;
Xml1.TransformArgumentList.AddParam("Page",
"",ss);
}
Если убрать последнюю строку - Xml1.TransformArgumentList.AddParam, все
работает. Если ее добавить - возникает ошибка
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 41: Xml1.DocumentSource=FileXML;Line 42:
Xml1.TransformSource = FileXSL;Line 43:
Xml1.TransformArgumentList.AddParam("Page", "",ss);
Menu4.xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="Page">Page1</xsl:param>
<xsl:param name="BaseRef">Page1</xsl:param>
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="Menu"/>
</xsl:template>
<xsl:template match="Menu">
<xsl:apply-templates select="MenuName"/>
</xsl:template>
<xsl:template match="MenuName">
<table width="110px" border="0" cellpadding="0px"
cellspacing="0px">
<tr>
<xsl:for-each
select="MenuItem">
<td
align="center" COLOR: red">
<xsl:value-of
select="@title"/>
</td>
</xsl:for-each>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
Menu3.xml
<?xml version="1.0" encoding="utf-8"?>
<Menu>
<MenuName>
<MenuItem NomPos="Pos1" link="Page1.aspx"
title="sdfsffsdf"></MenuItem>
<MenuItem NomPos="Pos2" link="Page2.aspx" title="2sdf"></MenuItem>
<MenuItem NomPos="Pos3" link="Page3.aspx" title="3fsdf"></MenuItem>
<MenuItem NomPos="Pos4" link="Page3.aspx" title="4jhjj"></MenuItem>
</MenuName>
</Menu>
With best regards, Kirik Alexander. E-mail: kirik[]ipnet.kiev.ua
begin 666 Alexander Kirik.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..DMI<FEK.T%L97AA;F1E<@T*
M1DXZ06QE>&%N9&5R($MI<FEK#0I%34%)3#M04D5&.TE.5$523D54.FMI<FEK
M0&UD;V9F:6-E+F-O;2YU80T*4D56.C(P,#4Q,# Y5#(Q,3<Q,EH-"D5.1#I6
&0T%21 T*
`
end
При попытке передать параметр в XSLT-файл возникает ошибка.
В aspx-файле:
<asp:Xml id="Xml1" runat="server" TransformSource="~\menu4.xslt"
DocumentSource="~\menu3.xml"></asp:Xml>
aspx.cs файл:
private void Page_Load(object sender, System.EventArgs e)
{
string ss="Page2";
string PathAp1 = Request.ApplicationPath;
string FileXML = PathAp1;
FileXML += "/Menu3.xml";
string FileXSL = PathAp1;
FileXSL += "/menu4.xslt";
Xml1.DocumentSource=FileXML;
Xml1.TransformSource = FileXSL;
Xml1.TransformArgumentList.AddParam("Page",
"",ss);
}
Если убрать последнюю строку - Xml1.TransformArgumentList.AddParam, все
работает. Если ее добавить - возникает ошибка
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
Line 41: Xml1.DocumentSource=FileXML;Line 42:
Xml1.TransformSource = FileXSL;Line 43:
Xml1.TransformArgumentList.AddParam("Page", "",ss);
Menu4.xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="Page">Page1</xsl:param>
<xsl:param name="BaseRef">Page1</xsl:param>
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="Menu"/>
</xsl:template>
<xsl:template match="Menu">
<xsl:apply-templates select="MenuName"/>
</xsl:template>
<xsl:template match="MenuName">
<table width="110px" border="0" cellpadding="0px"
cellspacing="0px">
<tr>
<xsl:for-each
select="MenuItem">
<td
align="center" COLOR: red">
<xsl:value-of
select="@title"/>
</td>
</xsl:for-each>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
Menu3.xml
<?xml version="1.0" encoding="utf-8"?>
<Menu>
<MenuName>
<MenuItem NomPos="Pos1" link="Page1.aspx"
title="sdfsffsdf"></MenuItem>
<MenuItem NomPos="Pos2" link="Page2.aspx" title="2sdf"></MenuItem>
<MenuItem NomPos="Pos3" link="Page3.aspx" title="3fsdf"></MenuItem>
<MenuItem NomPos="Pos4" link="Page3.aspx" title="4jhjj"></MenuItem>
</MenuName>
</Menu>
With best regards, Kirik Alexander. E-mail: kirik[]ipnet.kiev.ua
begin 666 Alexander Kirik.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..DMI<FEK.T%L97AA;F1E<@T*
M1DXZ06QE>&%N9&5R($MI<FEK#0I%34%)3#M04D5&.TE.5$523D54.FMI<FEK
M0&UD;V9F:6-E+F-O;2YU80T*4D56.C(P,#4Q,# Y5#(Q,3<Q,EH-"D5.1#I6
&0T%21 T*
`
end