Results 1 to 2 of 2

Thread: [RESOLVED] XSLT - Unable to get Page Title value passing ID

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2001
    Posts
    48

    Resolved [RESOLVED] XSLT - Unable to get Page Title value passing ID

    I have a sample application that I have simplified the xslt and xml file down to where I am having the problem and removing all the extra code.
    I am unable to get the function to return me the Page Title that matches the id="page_1"
    I do not get any errors.
    The result string contains the table, row and cell.
    The cell should contain the Page title and does not.

    Here is my simplified xslt file: test.xslt

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove">
    <xslutput method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="yes"></xslutput>
    <xsl:template match="/">
    <xslaram name="pageid"/>
    <table>
    <tr>
    <td>
    <xsl:value-of select="FORM/PAGES/PAGE[@id=$pageid]/@title" />
    </td>
    </tr>
    </table>
    </xsl:template>
    </xsl:stylesheet>

    Here is my xml document: test.xml
    <?xml version="1.0" encoding="utf-8"?>
    <FORM>
    <PAGES>
    <PAGE title="Page Title" id="page_1">
    </PAGE>
    </PAGES>
    </FORM>

    My code in vb .net 2005
    I am passing to this function pageId="page_1"

    Public Function TransformFields(ByVal pageId As String) As String *


    Dim xdoc As XmlDocument = New XmlDocument
    Dim XmlFile As String = ControlHolder.Page.Server.MapPath("~/test.xml")
    xdoc.Load(XmlFile)

    Dim xsl As XslCompiledTransform = New XslCompiledTransform(True)
    Dim XslFile As String = ControlHolder.Page.Server.MapPath("~/test.xslt")
    xsl.Load(XslFile)

    Dim xslArg As XsltArgumentList = New XsltArgumentList
    xslArg.AddParam("pageid", "", pageId)

    Dim sw As StringWriter = New StringWriter
    xsl.Transform(xdoc, xslarg, sw)

    Dim result As String = sw.ToString()

    sw.Close()

    Return result

    End Function

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2001
    Posts
    48

    Re: XSLT - Unable to get Page Title value passing ID

    Sorry, I posted to the wrong forum when I changed my sample from c# to vb.

    I found the problem.
    <xsl:template match="/">
    <xslaram name="pageid"/>
    Inside the xslt file these 2 lines need to be in reversed order
    Evidentally in .net 1.0 the order of these 2 lines don't matter as the sample came from .net 1.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width