dressman
asked on
Use XsltArgumentList to pass param to XSLT to filter XML file
What I am trying to do is display only a certain Page information but when i use:
Xml1.DocumentSource = Server.MapPath("_Data/Cont ent.xml")
Xml1.TransformSource = Server.MapPath("_Data/Cont ent.xslt")
it will display all of the information. Not just SandVolleyball or Childcare. I would like to pass a parameter to the XSLT and display only that page information.
XML:
<root>
<page>
<id>SandVolleyball</id>
<description>5 Professional Sand Volleyball Courts!</description>
<misc></misc>
<group>
<title>Sand Volleyball Rates</title>
<misc></misc>
<item>
<title>1 Hour Rental/Court</title>
<fee>$6.00</fee>
</item>
</group>
</page>
<page>
<id>ChildCare</id>
<description>Our experienced childcare attendants are eager to work with your children</description>
<misc></misc>
<group>
<title>Child Care Rates</title>
<misc></misc>
<item>
<title>20 Punch Pass</title>
<fee>$26.00</fee>
</item>
</group>
</page>
</root>
-------------------------- ---------- -----
XSLT:
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<xsl:param name="pageID"/>
<xsl:for-each select="/root/page">
<xsl:value-of select="description"/><br />
<xsl:for-each select="group[id='$pageID' ]">
<xsl:value-of select="title"/><br />
<table>
<xsl:for-each select="item">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="fee"/></td>
</tr>
</xsl:for-each>
</table>
<xsl:value-of select="misc"/><br />
</xsl:for-each>
<xsl:value-of select="misc"/><br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This is a guess:
Dim doc As XPathDocument = New XPathDocument(Server.MapPa th("_Data/ Content.xm l"))
Dim xsldoc As New XslTransform
xsldoc.Load(Server.MapPath ("_Data/Co ntent.xslt "))
Dim args As New XsltArgumentList
args.AddParam("pageID", "", Request.QueryString.Item(" Page").ToS tring)
xsldoc.Transform(doc, args, Me.Xml1.Document, Nothing)
Please HELP!!!!
Xml1.DocumentSource = Server.MapPath("_Data/Cont
Xml1.TransformSource = Server.MapPath("_Data/Cont
it will display all of the information. Not just SandVolleyball or Childcare. I would like to pass a parameter to the XSLT and display only that page information.
XML:
<root>
<page>
<id>SandVolleyball</id>
<description>5 Professional Sand Volleyball Courts!</description>
<misc></misc>
<group>
<title>Sand Volleyball Rates</title>
<misc></misc>
<item>
<title>1 Hour Rental/Court</title>
<fee>$6.00</fee>
</item>
</group>
</page>
<page>
<id>ChildCare</id>
<description>Our experienced childcare attendants are eager to work with your children</description>
<misc></misc>
<group>
<title>Child Care Rates</title>
<misc></misc>
<item>
<title>20 Punch Pass</title>
<fee>$26.00</fee>
</item>
</group>
</page>
</root>
--------------------------
XSLT:
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<xsl:param name="pageID"/>
<xsl:for-each select="/root/page">
<xsl:value-of select="description"/><br />
<xsl:for-each select="group[id='$pageID'
<xsl:value-of select="title"/><br />
<table>
<xsl:for-each select="item">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="fee"/></td>
</tr>
</xsl:for-each>
</table>
<xsl:value-of select="misc"/><br />
</xsl:for-each>
<xsl:value-of select="misc"/><br />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This is a guess:
Dim doc As XPathDocument = New XPathDocument(Server.MapPa
Dim xsldoc As New XslTransform
xsldoc.Load(Server.MapPath
Dim args As New XsltArgumentList
args.AddParam("pageID", "", Request.QueryString.Item("
xsldoc.Transform(doc, args, Me.Xml1.Document, Nothing)
Please HELP!!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
'LoadXML(Request.QueryStri
Dim xslt As New XslTransform
xslt.Load(Server.MapPath("
'Create the XsltArgumentList.
Dim argList As New XsltArgumentList
argList.AddParam("pageID",
'Create the XmlTextWriter.
'Dim writer As New XmlTextWriter(Server.MapPa
'Transform the file.
Me.Xml1.TransformArgumentL
Me.Xml1.DocumentSource = Server.MapPath("_Data/Cont
Me.Xml1.TransformSource = Server.MapPath("_Data/Cont