Groups | Blog | Home
all groups > dotnet xml > may 2004 >

dotnet xml : .NET , XML , XSL -> XsltArgumentList : Question ?


NicoAgenci
5/6/2004 9:20:10 AM
Hello,

I have a page in .net (DEFAULT.ASPX), i load a XmlDocument, and a
XslTransform to Add a XsltArgumentList (with the param : urlPage), and send
all to a <asp:xml> in the page.

The <asp:xml> is good with xml and xsl, but the param is not fill with the
value ?

Do you have a solution ??? Thanx

---
DEFAULT.ASPX :
<script language="C#" runat="server">

private void Page_Load(object sender, System.EventArgs e)

{

String xmlPath = Server.MapPath("/data/page.xml") ;

String xslPath = Server.MapPath("/xsl/i_infoPage.xsl") ;

String strUrlPage = "/default.aspx";

String xpathPage = "page[url='" + strUrlPage + "']";


// Nouvo XmlDoc pour l'affichage des Infos de Page

XmlDocument xmldocInfo = new XmlDocument();

xmldocInfo.Load(xmlPath);

XslTransform xsltInfo = new XslTransform();

xsltInfo.Load(xslPath);

// Crée un Arg pour le passage en Xslt du Composant Asp:Xml

XsltArgumentList argsInfo = new XsltArgumentList();

argsInfo.AddParam("urlPage","", "'Nico'");

// Réalise la transformation

xsltInfo.Transform(xmldocInfo, argsInfo);


// Source Xml et Xslt pour le Composant AspXml

aspxmlInfo.Document = xmldocInfo;

aspxmlInfo.Transform = xsltInfo;

}

</script>

<asp:xml ID="aspxmlInfo" runat="server"></asp:xml>

DEFAULT.ASPX : FIN

---

I_INFOPAGE.XSL :



<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="html" indent="no" />

<xsl:param name="urlPage" />

<xsl:template match="/">

<xsl:apply-templates select="//page[userCreation=$urlPage]" />

</xsl:template>

<xsl:template match="page">

<table class="mainTable" border="0" cellpadding="0" cellspacing="0"
align="center" bgcolor="#FFFFFF">

<tr align="left" valign="top">

<td class="infoPage" style="padding-left: 209px"><xsl:value-of
select="userMiseajour" /> - <xsl:value-of select="dateMiseajour" /></td>

<td width="200" align="right" class="infoPage" style="padding-right:
8px">vu: <xsl:value-of select="vu" /></td>

</tr>

</table>

</xsl:template>

</xsl:stylesheet>

I_INFOPAGE.XSL :FIN


Oleg Tkachenko [MVP]
5/6/2004 12:41:05 PM
[quoted text, click to view]


[quoted text, click to view]

Well, above line is superfluous. Technically here you are starting XSL
transformation and not using its result. asp:xml control will do
transformation for you, that's its the only function. You only need to
provide source document, xsl stylesheet and optional parameters.

[quoted text, click to view]

Here is how you can provide parameters to asp:xml control:

aspxmlInfo.TransformArgumentList = argsInfo;

--
Oleg Tkachenko [XML MVP]
AddThis Social Bookmark Button