Jump to content

kwilliams

Members
  • Posts

    229
  • Joined

  • Last visited

Posts posted by kwilliams

  1. I created a simple Stored Procedure (SP) that queries a table and renames the column names, and I'm able to push those results out to a CSV file *with* those header names when done manually.But when I try to export the results to a CSV file by running the same SP using xp_cmdshell with bcp, the header row (Col1, Col2, and Col3) does not appear in the resulting CSV file.ORIGINAL TABLE:ColumnName1-----ColumnName2-----ColumnName3Joe Schmo CustomerJane Doe CustomerTim Tiny MusicianQUERY WITHIN SP:SELECT ColumnName1 AS Col1, ColumnName2 AS Col2, ColumnName3 AS Col3FROM TABLENAMEQUERY RESULT:Col1-----Col2-----Col3 <<<<----- WHAT I WANT!Joe Schmo CustomerJane Doe CustomerTiny Tim MusicianHere's the code I'm using within the job:EXEC xp_cmdshell 'bcp "EXEC DATABASENAME.dbo.STOREDPROCEDURENAME" QUERYOUT "\\MYSERVERNAME\files\export.csv" -c -t, -T -S'CSV FILE RESULT USING BCP:Joe Schmo CustomerJane Doe CustomerTim Tiny MusicianAs you can see the headers are missing. What am I doing wrong?

  2. <span style='font-family:Lucida Console'>I don't understand what you mean by that... are you saying that your menu is not loading on top of your form fields? O_o? A link to your site or your code would help.... or that your menu is not loading above of your form fields? If that's the case make sure that your menu is above the <form> tag and not inside of it.</span>
    Hallelujah! I've found an answer by looking at one of the sources of my CSS menu...suckerfish. And it works great.Here's an article on how to do exactly what I needed: http://tanny.ica.com/ICA/TKO/tkoblog.nsf/d...p-in-ie-part-ii...and here's an example page that they created to show how it works: http://tanny.ica.com/ICA/TKO/test.nsf/####.../examplefix.htm This solution uses the iframe method mentioned previously in this post, while allowing only part of the select menu to be hidden. Hopefully this will help other developers in the future. Thanks for all of your help.
  3. My problem is that my application properly pulls an ASP.NET file on my machine using Visual Web Developer 2005, but it doesn't pull it properly when a copy of the application was uploaded to our test server. On my machine, I listed the entire path for the ASP.NET doc to be pulled (c:\Documents and Settings\MYUSERNAME\My Documents\Visual Studio 2005\Projects\DIRECTORY\SUBDIRECTORY\PAGE.aspx). On the test server, I'm attempting to pull the ASP.NET doc with a UNC share (\\SERVERNAME\DIRECTORY\SUBDIRECTORY\PAGE.aspx).I'm using the FileInfo Class to do this, and I've included the two versions of code below. If anyone could please let me know what I'm doing wrong, that would be great. (Hopefully it's something obvious) Thanks.OLD METHOD ON MACHINE:

    Partial Class MasterPage	Inherits System.Web.UI.MasterPage	Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)		'Assign page path to string value		Dim strPagePath = Request.ServerVariables("PATH_INFO")		Response.Write("<strong>strPagePath: </strong>" & strPagePath & "<br />") 'test		'Assign full page path		Dim strFullPagePath = "c:\Documents and Settings\MYUSERNAME\My Documents\Visual Studio 2005\Projects" & strPagePath		'Assign path to FileInfo Class		Dim fi As FileInfo = New FileInfo(strFullPagePath)		Dim strPageId As String, strPathNoFileName As String		Dim strXMLPath_mc As String, strXSLPath_mc As String, strCSSPath As String		'Check if files exist		If Not fi.Exists Then			strPageId = "default"			strPathNoFileName = "http://localhost:1309/DIRECTORYNAME"		Else			strPageId = fi.Name.Replace(fi.Extension, "") 'without extension			strPathNoFileName = strPagePath.Replace(fi.Name, "")			'Assign dynamic page paths			strXMLPath_mc = strPathNoFileName + "docs/xml/" & strPageId & ".xml" 'xml doc			strXSLPath_mc = strPathNoFileName + "docs/xslt/" & strPageId & ".xsl" 'xsl doc			strCSSPath = strPathNoFileName + "docs/css/" & strPageId & ".css" 'css doc		End If	End SubEnd Class

    RESULTING VALUE:strFullPagePath = "c:\Documents and Settings\MYUSERNAME\My Documents\Visual Studio 2005\Projects\DIRECTORY\SUBDIRECTORY\PAGE.aspx"NEW METHOD ON TEST SERVER:

    Partial Class MasterPage	Inherits System.Web.UI.MasterPage	Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)		'Assign page path to string value		Dim strPagePath = Request.ServerVariables("PATH_INFO")	Dim strPagePath_fi As String = strPagePath.Replace("/", "\") 'replace slash	Dim strFullPagePath = "\\SERVERNAME\DIRECTORY" & strPagePath_fi '<---THIS IS THE PROBLEM		'Assign path to FileInfo Class		Dim fi As FileInfo = New FileInfo(strFullPagePath)		Dim strPageId As String, strPathNoFileName As String		Dim strXMLPath_mc As String, strXSLPath_mc As String, strCSSPath As String		'Check if files exist		If Not fi.Exists Then			strPageId = "default"		strPathNoFileName = "http://SERVERNAME/DIRECTORY"		Else			strPageId = fi.Name.Replace(fi.Extension, "") 'without extension			strPathNoFileName = strPagePath.Replace(fi.Name, "")			'Assign dynamic page paths			strXMLPath_mc = strPathNoFileName + "docs/xml/" & strPageId & ".xml" 'xml doc			strXSLPath_mc = strPathNoFileName + "docs/xslt/" & strPageId & ".xsl" 'xsl doc			strCSSPath = strPathNoFileName + "docs/css/" & strPageId & ".css" 'css doc		End If	End SubEnd Class

    RESULTING VALUE:strFullPagePath = "\\SERVERNAME\DIRECTORY\SUBDIRECTORY\PAGE.aspx"

  4. Try this...
    var strValue_original = "ababab"var strA = "ZZ~";var strB = "YY~";var strValue_display = strValue_original;strValue_display = strValue_display.replace(/a/g,strA);document.write("strValue_display (a):" + strValue_display + "<br />");strValue_display = strValue_display.replace(/b/g,strB);document.write("strValue_display (b):" + strValue_display + "<br />");

    It worked great! Thanks for the quick response.
  5. I'm trying to use the replace method to replace all instances of "a" and "b" characters within a string, but I'm running into a problem. I have accomplished this in my VB version without a problem, but the JavaScript version is only replacing the first instance of the character in the string. I've included all of the referenced code below. If anyone could please let me know what I'm doing wrong, that would be great. Thanks for any and all help.Problem: JS version replaces only the first instance of a character, while the VB version replaces all instances of characters.Example value: bababaVB version (works):'Declare variablesDim strA As String = "ZZ~"Dim strB As String = "YY~"Dim strValue_display As String = strValue_originalstrValue_display = strValue_display.replace("a",strA)Response.Write("strValue_display (a):" & strValue_display & "<br />")strValue_display = strValue_display.replace("b",strB)Response.Write("strValue_display (:):" & strValue_display & "<br />")'Resulting value: YY~ZZ~YY~ZZ~YY~ZZ~JScript version (doesn't work)://Declare variablesvar strA = "ZZ~";var strB = "YY~";var strValue_display = strValue_original;strValue_display = strValue_display.replace("a",strA);Response.Write("strValue_display (a):" + strValue_display + "<br />");strValue_display = strValue_display.replace("b",strB);Response.Write("strValue_display (:):" + strValue_display + "<br />");//Resulting value: YY~ZZ~baba

  6. jesh...You make a very good point concerning future compatibility with ASP.NET vs. XSLT.What I liked about the web.sitemap feature most was being able to use the navigational features, especially the breadcrumbs. I now realize that I can use the same model for a XSLT transformation of internal_links.xml.boen_robot...I gave your suggested code a try, and this was the output:

    ...<!-- Dynamic MainColumn -->			<div id="screenmain">				<!-- dynamic page title -->				<h1><span id="ctl00_lblPageTitle">About Us</span></h1>				<br />				<span id="ctl00_SiteMapPath1"><a href="#ctl00_SiteMapPath1_SkipLink"><img alt="Skip Navigation Links" height="0" width="0" src="/phase3/WebResource.axd?d=AvErmV8chiUAyOw6Ne1jOA2&t=632996128439938112" style="border-width:0px;" /></a><span><a href="/phase3/default.aspx">Home Page</a></span><span> > </span><span>About Us</span><a id="ctl00_SiteMapPath1_SkipLink"></a></span>				<br />				<hr class="navyblueline" />				<br />				<span id="ctl00_lblPageDesc">This page contains links to information about us.</span>				<br /><br />				<?xml version="1.0" encoding="utf-8"?><ul>  <li>	<a href=""></a>: </li></ul>			</div><!-- end screenmain -->...

    ...but since I'm going to use the original model with the code I already have developed for internal_links.xml, I won't need to use this filter anyway. Again, I really appreciate all of your help, as it's given me some great tools to accomplish what I need to do. I'll make sure to let you know when I have a complete solution so that you can check it out if you wish.Thanks everyone:)

  7. You might consider posting in the .NET forum. I am a .NET developer who doesn't know very much about XSLT but I happened to take a look at this forum yesterday. Perhaps one of the .NET developers here knows more about XSLT but also doesn't look at this forum much.
    Will do. Thanks:)
  8. Well, thanks jesh. I'll give that setup a try. I haven't heard any more from other users on the subject of XSLT vs. ASP.NET for display and manipulation of XML data, but hopefully some advice will come in. Thanks for your suggestion and code:)

  9. What exactly do you need this filter for? Sample scenario?
    I want to have a list of keywords on an XML doc, like this:<aboutus> <internal_links> <link>arealinks</link> <link>faqs</link> <link>contactus</link> </internal_links></aboutus>...and then I want to pull only the properties for those specific links using the "id" attribute in Web.sitemap, so that:<ul> <xsl:for-each select="aboutus/internal_link[link != '']"><!-- SOMETHING LIKE THIS --> <xsl:variable name="url" select="$websitemap/siteMap/siteMapNode/@url" /><!-- SOMETHING LIKE THIS --> <xsl:variable name="title" select="$websitemap/siteMap/siteMapNode/@title" /><!-- SOMETHING LIKE THIS --> <xsl:variable name="description" select="$websitemap/siteMap/siteMapNode/@description" /><!-- SOMETHING LIKE THIS --> <li><a href="{$url}><xsl:value-of select="$title" /></a>: <xsl:value-of select="$description" /></li><!-- SOMETHING LIKE THIS --> </xsl:for-each></ul>...but I'm not sure how to call and loop it properly, since all of the nodes in Web.sitemap use a heirchecy. If you know how I can accomplish this, your help would be great.
    I probably would have written PageHandlers to deal with the different content types, but there are always more than one way to do something! I just want to give one more piece of advice - You can get the child nodes of any SiteMapNode like so:
    SiteMap.CurrentNode.ChildNodes

    If you are currently on "AboutUs", and "AboutUs" has a child node of "AreaLinks", then the return value of SiteMap.CurrentNode.ChildNodes is a one-element, one-dimensional array of SiteMapNodes which contains the SiteMapNode for "AreaLinks". This might be an easier way than parsing the entire XML file on your own and looking for a specific ID.OK, carry on the XSLT discussion. :)

    That setup would work great if I was only using ASP.NET with XML, but since I'm using XSLT to process the individual pages and Web.sitemap in addition to the ASP.NET Master Page, that wouldn't work for me. However, I have been thinking of whether or not it would be easier for me to scrap the use of XSLT in favor of using ASP.NET to display the data from XML. Mostly because creating forms in XSLT and passing that data to and from the ASP.NET/VB/NET docs with this setup has been a real pain in the you know what. One concern I'd have with this switch would be the ability to also transform that data into other formats, but the "PageHandlers" method you mentioned sounds interesting. Could you please point me in the right direction to some resources on that method?Also, if anyone can submit a list of pros and cons to XSLT vs. ASP.NET on this post, that would also be great. Thanks for any & all help.
  10. So, I've sort of been following this one. Why exactly are you using XSLT for this? Are you just trying to create a link from your sitemap file? It seems to me that it'd be much easier to do something like this:MasterPage.master:
    ...<asp:HyperLink id="SiteMapLink" runat="server />...

    MasterPage.master.vb:

    ...SiteMapLink.Text = SiteMap.CurrentNode.TitleSiteMapLink.NavigateUrl = SiteMap.CurrentNode.Url...

    Of course, I could be totally wrong - I didn't even know that the SiteMap class existed. :-P

    *Hi jesh,I wanted a completely dynamic site that contains the basic properties on one central page (MasterPage.master), and dynamic properties from data stored in XML documents. I also wanted to use XSLT to display the data, so that I can later easily transform the data into other formats, including PDF, RSS, etc. And finally, I wanted the transformation to be able to use code-behind for each of those pages.So I'm converting my entire site to store data in XML, and display it using XSLT with a ASP.NET transformation. I'm using the one central web.sitemap doc to store the entire site's navigation, so that I can use it from the Master page and the XSLT stylesheets. This setup allows one Master Page to process a page's static properties from the Web.sitemap doc by calling specific nodes from that sitemap into the page-specific XSLT stylesheet. So when I'm done, aboutus.xml will only call nodes in Web.sitemap that have an id of "arealinks", which will display a link to the "Area Links" page. I already had this setup with a central XML file called "internal_links.xml", but since I wanted to use the sitemap class throughout the site, I decided to try to figure out a way to do this using "Web.sitemap" instead.My current setup doesn't have a filter for the "id" attribute yet, so it's just displaying the entire sitemap in an unordered list. So this is what my current setup looks like:MasterPage.master
    <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" Debug="True" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">	<title id="lblBrowserTitle"></title>	<link rel="stylesheet" type="text/css" media="screen" href="~/docs/css/screen.css" /></head><body>	<form id="form1" runat="server">		<div id="wrapper">			<div id="screenheader">				<div id="seal">					<asp:Image 						id="Image1"						ImageUrl="~/images/gif/seal.gif" Runat="Server" />				</div><!-- end seal -->				<div id="header">					<asp:Image 						id="Image2"						ImageUrl="~/images/gif/header.gif" Runat="Server" />				</div><!-- end header -->				<div id="graphic">					<asp:Image 						id="Image4"						ImageUrl="~/images/gif/graphic.gif" Runat="Server" />				</div><!-- end graphic -->				<div id="blueborder">					<div id="date_today">						<asp:label id="lblCurrDate" runat="server" />					</div>					<div id="header_links">						<a class="white" href="">Help</a> | 						<a class="white" href="">Contact Us</a> | 						<a class="white" href="">Text-only Version</a> | 						<a class="white" href="">Printer-friendly Version</a>					</div><!-- end header_links -->				</div><!-- end blueborder -->				<div id="gradientline">					<asp:Image 						id="Image5"						ImageUrl="~/images/gif/gradientline.gif" Runat="Server" />				</div><!-- end gradientline -->								<!-- Tab navigation -->				<div id="tabs">					<a href="http://localhost:1309/phase3/default.aspx"><asp:Image id="Image7" ImageUrl="images/gif/tab1.gif" Runat="server" /></a>					<a href="http://localhost:1309/phase3/aboutus/aboutus.aspx"><asp:Image id="Image8" ImageUrl="images/gif/tab2.gif" Runat="server" /></a>				</div><!-- end tabs -->			</div><!-- end screenheader -->						<!-- Dynamic MainColumn -->			<div id="screenmain">				<!-- dynamic page title -->				<h1><asp:label id="lblPageTitle" runat="server" /></h1><!-- dynamic page title -->				<br />				<asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath><!-- dynamic breadcrumbs -->				<br />				<hr class="navyblueline" />				<br />				<asp:label id="lblPageDesc" runat="server" /><!-- dynamic page description -->				<br /><br />				<asp:Xml id="xslTransform_mc" runat="server"></asp:Xml><!-- dynamic XML/XSLT content -->				<asp:contentplaceholder					id="MainColumn"					runat="server">				</asp:contentplaceholder><!-- link to code behind script(s) for specific page -->			</div><!-- end screenmain_modules -->			<!-- Footer -->			<div id="screenfooter">				<hr class="navyblueline" />				<a href="">Help</a> | 				<a href="">Contact Us</a> | 				<a href="">Text-only Version</a> | 				<a href="">Printer-friendly Version</a>				<br />			</div><!-- end screenfooter -->		</div><!-- end wrapper -->	</form></body></html>

    MasterPage.master.vb

    Partial Class MasterPage	Inherits System.Web.UI.MasterPage	Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)		'Current date		Dim dtCurrDate As DateTime = DateTime.Now 'Assign current date		Dim strCurrDate As String = dtCurrDate.ToLongDateString 'format date		lblCurrDate.Text = strCurrDate 'Assign date to label		'Pull page path		Dim strPagePath = Request.ServerVariables("PATH_INFO")		'Assign full page path		Dim strFullPagePath = "c:\Documents and Settings\MYUSERNAME\My Documents\Visual Studio 2005\Projects" & strPagePath 'TEMPORARY		'Assign path to FileInfo Class		Dim fi As FileInfo = New FileInfo(strFullPagePath)		Dim strPageId As String, strPathNoFileName As String		Dim strXMLPath_mc As String, strXSLPath_mc As String, strCSSPath As String		'Check if files exist		If Not fi.Exists Then			strPageId = "default"			strPathNoFileName = "http://localhost:1309/phase3"		Else			strPageId = fi.Name.Replace(fi.Extension, "") 'without extension			strPathNoFileName = strPagePath.Replace(fi.Name, "")			'Assign dynamic page paths			strXMLPath_mc = strPathNoFileName + "docs/xml/" & strPageId & ".xml" 'xml doc			strXSLPath_mc = strPathNoFileName + "docs/xslt/" & strPageId & ".xsl" 'xsl doc			strCSSPath = strPathNoFileName + "docs/css/" & strPageId & ".css" 'css doc		End If		'Declare variables from XML nodes		Dim page_id As String, page_title As String, sortby As String, sorttype As String, sortorder As String		Dim short_description As String, long_description As String		Dim meta_keywords As String, meta_description As String		Dim leftcolumn As String, rightcolumn As String, css As String		Dim strXMLPath_lc As String, strXSLPath_lc As String		Dim strXMLPath_rc As String, strXSLPath_rc As String		Dim objNodeExists As Object = False		'Load MainContent XML file internal_links.xml and assign page properties		Dim il_xmld As XmlDocument		Dim il_nodelist As XmlNodeList		Dim il_node As XmlNode		'Create the XML Document		il_xmld = New XmlDocument()		'Load the Xml file		il_xmld.Load("http://SERVERNAME/docs/xml/internal_links.xml")		'Get the list of name nodes		il_nodelist = il_xmld.SelectNodes("/internal_links/page[@id = '" & strPageId & "']")		'Loop through the nodes		For Each il_node In il_nodelist			'Assign object if node is not empty			objNodeExists = True			'Get an Attribute Value			page_id = il_node.Attributes.GetNamedItem("id").Value			'Pull XML nodes			page_title = il_node.Item("title").InnerText			sortby = il_node.Item("sortby").InnerText			sorttype = il_node.Item("sorttype").InnerText			sortorder = il_node.Item("sortorder").InnerText			short_description = il_node.Item("short_description").InnerText			long_description = il_node.Item("long_description").InnerText			meta_keywords = il_node.Item("meta_keywords").InnerText			meta_description = il_node.Item("meta_description").InnerText			css = il_node.Item("css").InnerText		Next 'end loop		'Assign page-specific properties		lblBrowserTitle.Text = SiteMap.CurrentNode.Title 'Page title label		lblPageTitle.Text = SiteMap.CurrentNode.Title 'Page title label		lblPageDesc.Text = SiteMap.CurrentNode.Description 'Page desc. label		'Assign maincolumn XML/XSLT transformation properties		xslTransform_mc.DocumentSource = strXMLPath_mc		xslTransform_mc.TransformSource = strXSLPath_mc	End SubEnd Class

    Web.sitemap

    <?xml version="1.0" encoding="utf-8" ?><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >	<siteMapNode url="~/default.aspx" title="Home Page" id="default" description="This is the home page.">		<siteMapNode url="~/aboutus/aboutus.aspx" title="About Us" description="This page contains information about us." id="aboutus">			<siteMapNode url="~/aboutus/arealinks.aspx" title="Area Links" description="This page contains a list of several area links." id="arealinks" />		</siteMapNode>	</siteMapNode></siteMap>

    aboutus.xml

    <?xml version="1.0" encoding="UTF-8"?><aboutus>	<internal_links>		<link>arealinks</link>	</internal_links></aboutus>

    aboutus.xsl

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sm="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" exclude-result-prefixes="sm"><xsl:output method="xml" encoding="UTF-8" indent="yes"/><xsl:variable name="websitemap" select="document('c:\Documents and Settings\MYUSERNAME\My Documents\Visual Studio 2005\Projects\phase3\Web.sitemap')" /><xsl:include href="http://localhost:1309/phase3/aboutdc/docs/xslt/siteMap.xsl" />	<xsl:template match="/">		<div id="navigation">			<xsl:for-each select="$websitemap">				<xsl:apply-templates select="sm:siteMap" /><!-- displays all nodes in web.sitemap -->			</xsl:for-each>		</div>		<div id="content">					<xsl:apply-templates/>			</div>	</xsl:template></xsl:stylesheet>

    HTML Output

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>	<title>About Us</title>	<link rel="stylesheet" type="text/css" media="screen" href="../docs/css/screen.css" /></head><body>	<form name="aspnetForm" method="post" action="aboutus.aspx" id="aspnetForm">	<div>		<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMTgxMjAzNjcwD2QWAmYPZBYEAgEPZBYCAgQPFgIeBGhyZWYFJC9waGFzZTMvYWJvdXRkYy9kb2NzL2Nzcy9hYm91dGRjLmNzc2QCAw9kFgYCCQ8PFgIeBFRleHQFFk1vbmRheSwgTWFyY2ggMTIsIDIwMDdkZAIhDw8WAh8BBRBBYm91dCB0aGUgQ291bnR5ZGQCJQ8PFgIfAQVFVGhpcyBwYWdlIGNvbnRhaW5zIGxpbmtzIHRvIGluZm9ybWF0aW9uIGFib3V0IERvdWdsYXMgQ291bnR5LCBLYW5zYXMuZGRk2g9UZR9pZEK1qBOQCwl68toMwa8=" />	</div>	<div id="wrapper">		<div id="screenheader">			<div id="seal">				<img id="ctl00_Image1" src="../images/gif/seal.gif" style="border-width:0px;" />			</div><!-- end seal -->			<div id="header">				<img id="ctl00_Image2" src="../images/gif/header.gif" style="border-width:0px;" />			</div><!-- end header -->			<div id="graphic">				<img id="ctl00_Image4" src="../images/gif/graphic.gif" style="border-width:0px;" />			</div><!-- end graphic -->			<div id="blueborder">				<div id="date_today">					<span id="ctl00_lblCurrDate">Monday, March 12, 2007</span>				</div>				<div id="header_links">					<a class="white" href="">Help</a> | 					<a class="white" href="">Contact Us</a> | 					<a class="white" href="">Text-only Version</a> | 					<a class="white" href="">Printer-friendly Version</a>				</div><!-- end header_links -->			</div><!-- end blueborder -->			<div id="gradientline">				<img id="ctl00_Image5" src="../images/gif/gradientline.gif" style="border-width:0px;" />			</div><!-- end gradientline -->							<!-- Tab navigation -->			<div id="tabs">				<a href="http://localhost:1309/phase3/default.aspx"><img id="ctl00_Image7" src="../images/gif/tab1.gif" style="border-width:0px;" /></a>				<a href="http://localhost:1309/phase3/aboutus/aboutus.aspx"><img id="ctl00_Image8" src="../images/gif/tab2.gif" style="border-width:0px;" /></a>			</div><!-- end tabs -->		</div><!-- end screenheader -->				<!-- Dynamic MainColumn -->		<div id="screenmain_modules">			<!-- dynamic page title -->			<h1><span id="ctl00_lblPageTitle">About Us</span></h1>			<br />			<span id="ctl00_SiteMapPath1"><a href="#ctl00_SiteMapPath1_SkipLink"><img alt="Skip Navigation Links" height="0" width="0" src="/phase3/WebResource.axd?d=AvErmV8chiUAyOw6Ne1jOA2&t=632996128439938112" style="border-width:0px;" /></a><span><a href="/phase3/default.aspx">Home Page</a></span><span> > </span><span>About Us</span><a id="ctl00_SiteMapPath1_SkipLink"></a></span>			<br />			<hr class="navyblueline" />			<br />			<span id="ctl00_lblPageDesc">This page contains links to information about Douglas County, Kansas.</span>			<br /><br />			<?xml version="1.0" encoding="utf-8"?>			<div id="navigation">				<ul>					<li><a id="default" href="~/default.aspx">Home Page<ul>						<li><a id="aboutus" href="~/aboutus/aboutus.aspx" title="This page contains links to information about us.">About Us<ul>							<li><a id="arealinks" href="~/aboutus/arealinks.aspx" title="This page contains a list of several area links for Douglas County, Kansas.">Area Links</a></li>						</ul></a></li>					</ul></a></li>				</ul>			</div>			<div id="content"><!-- output from XML doc -->				arealinks			</div>		</div><!-- end screenmain -->				<!-- Footer -->		<div id="screenfooter">					<hr class="navyblueline" />					<br />					<a href="">Help</a> | 					<a href="">Contact Us</a> | 					<a href="">Text-only Version</a> | 					<a href="">Printer-friendly Version</a>					<br />		</div><!-- end screenfooter -->	</div><!-- end wrapper -->	</form></body></html>

  11. What exactly is the final output? If it's:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><body>	<form id="form1" runat="server">	</form></body></html>

    There's some error in the ASP code. If it's

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><body>	<form id="form1" runat="server">		<div id="navigation">		</div>		<div id="content">		</div>	</form></body></html>

    Then probably the URI to web.sitemap is wrong. Try to give it an absolute path, or place it in the same folder as the XSLT or the ASP.If it's neighter of those, we seriously need Gobby.

    Well, I have some really good news. After messing around with the URI, I found a way to make it work. I had to change the path for the Web.sitemap doc from http://localhost:1309/phase3/Web.sitemap to c:\Documents and Settings\MYUSERNAME\My Documents\Visual Studio 2005\Projects\phase3\Web.sitemap. I guess since I'm testing this all out on my machine, I'll have to put the direct path to the file on my machine until it's launched. At that point, I should be able to use a regular URI, like http://www.mysite.com/Web.sitemap.So now that I have the sitemap file being pulled in, I'm next going to work at filtering a specific node from the sitemap using my custom "id" attribute. I'll post any such code when I get it done. Thanks for all of your help and patience. It's been a very eye-opening experience.
  12. Declaring the namespace in aboutus.xsl turned out to be needed after all. I realized I first used web.sitemap as my input file, when I shouldn't have. A quick test with a new (empty) XML showed otherwise. Here's my aboutus.xsl (sitemap.xsl is exactly the same):....CODEP.S. You do know you can safely remove the comments, right?
    I added the namespace back to aboutus.xsl, but no data appears on the transformed docs. Here's everything that I'm using so far...including the removal of your comment tags:)Web.sitemap
    <?xml version="1.0" encoding="utf-8" ?><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >  <siteMapNode url="~/default.aspx" title="Home Page" id="default">	<siteMapNode url="~/aboutus/aboutus.aspx" title="About Us" description="This page contains links to information about us." id="aboutus">  </siteMapNode></siteMap>[b]aboutus.xsl[/b][code]<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sm="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" exclude-result-prefixes="sm"><xsl:output method="xml" encoding="UTF-8" indent="yes"/><xsl:include href="siteMap.xsl" />	<xsl:template match="/">		<div id="navigation">			<xsl:for-each select="document('Web.sitemap')">				<xsl:apply-templates select="sm:siteMap" />			</xsl:for-each>		</div>		<div id="content">			<xsl:apply-templates/>		</div>	</xsl:template></xsl:stylesheet>

    sitemap.xsl

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sm="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" exclude-result-prefixes="sm">	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>	<xsl:template name="map" match="sm:siteMap">		<ul>			<xsl:apply-templates/>		</ul>	</xsl:template>	<xsl:template match="sm:siteMapNode">		<li>			<a id="{@id}" href="{@url}">				<xsl:if test="@description">					<xsl:attribute name="title">						<xsl:value-of select="@description"/>					</xsl:attribute>				</xsl:if>				<xsl:value-of select="@title"/>				<xsl:if test="sm:siteMapNode">					<xsl:call-template name="map"/>				</xsl:if>			</a>		</li>	</xsl:template></xsl:stylesheet>

    And here's the transformation using the ASP.NET Master Page method:MasterPage.master.vb:

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)	xslTransform_mc.DocumentSource = "docs/xml/aboutus/aboutus.xml" 'xml doc		xslTransform_mc.TransformSource = "docs/xslt/aboutus/aboutus.xsl" 'xsl docEnd Sub

    MasterPage.master:

    <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" Debug="True" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><body>	<form id="form1" runat="server">		<asp:Xml id="xslTransform_mc" runat="server"></asp:Xml>	</form></body></html>

    I also tried transforming the two docs (aboutus.xml and aboutus.xsl) within a simple static ASP.NET doc, but it's still not showing any data. I added the siteMap.xsl code to the aboutus.xsl page directly, and temporarily removed the include to see if the issue was that it wasn't pulling the siteMap.xsl doc, but it didn't make a difference. And finally, I copied all of the pages to an internal test server to see if it was because it's using my machine's test server, but it made no difference. So I'm basically stuck as to why it's working for you and not me. Please let me know if you see anything that's obviously wrong (hopefully), and thanks for your help.

  13. !!!!!!!!!!!!Like so:
    <xsl:for-each select="document('http://localhost:1309/phase3/Web.sitemap')">

    By the way, declaring the namespace in aboutus.xsl wasn't required for this to run. Declaring it non the less is not a bad idea though, so go ahead.

    Good morning boen_robot,Sorry that I didn't notice your comment about removing the slash from the document() function, but I just did so, and the error was gone. But no links or other data is being displayed. I also removed the namspace from aboutus.xsl just to make sure that our code was matching properly. So we're making progress. Obviously the data from the siteMap.xsl stylesheet is not being called from the aboutus.xsl doc, so if you could make sure that I'm calling everything properly on the aboutdc.xsl doc. that would be great. I think that we're almost there...hopefully:)To make sure that we're on the same page, this is what the 2 docs look like now after your suggested revisions:siteMap.xsl
    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sm="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" exclude-result-prefixes="sm">	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>	<xsl:template name="map" match="sm:siteMap">		<ul>			<xsl:apply-templates/>		</ul>	</xsl:template>	<xsl:template match="sm:siteMapNode">		<li>			<a id="{@id}" href="{@url}">				<xsl:if test="@description">					<xsl:attribute name="title">						<xsl:value-of select="@description"/>					</xsl:attribute>				</xsl:if>				<xsl:value-of select="@title"/>				<xsl:if test="sm:siteMapNode">					<xsl:call-template name="map"/>				</xsl:if>			</a>		</li>	</xsl:template></xsl:stylesheet>

    aboutus.xsl

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/><xsl:include href="siteMap.xsl"/><!-- this includes the file above -->	<xsl:template match="/"><!-- this can of course be anything you'd like -->		<div id="navigation">			<!--You can change the file's URI from here -->			<xsl:for-each select="document('http://localhost:1309/phase3/Web.sitemap')">				<!-- if you want to use templates from the main file during the site map's generation, remove the select attribute -->				<xsl:apply-templates select="sm:siteMap"/>			</xsl:for-each>		</div>		<div id="content">			<xsl:apply-templates/>		</div>	</xsl:template></xsl:stylesheet>

  14. Well, I gave it a try by adding the namespace and adding the prefix to the stylesheet on siteMap.xsl doc, and by adding a prefix to the aboutus.xsl "apply-templates" call, like this:<xsl:apply-templates select="sm:siteMap"/>but I'm still receiving the same error message:Exception Details: System.Xml.XPath.XPathException: Expression must evaluate to a node-set.Since you were able to get it working, next I'm going to create a simple static XSLT transformation within a basic ASP.NET doc, and I'll let you know what happens. Thanks again.

  15. First off, thanks for all of your help boen_robot. It's really appreciated by me.Well, I created an XSLT doc titled siteMap.xsl with the following code:

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/>	<xsl:template name="map" match="siteMap">		<ul>			<xsl:apply-templates/>		</ul>	</xsl:template>	<xsl:template match="siteMapNode">		<li>			<a id="{@id}" href="{@url}">				<xsl:if test="@description">					<xsl:attribute name="title"><xsl:value-of select="@description"/></xsl:attribute>				</xsl:if>				<xsl:value-of select="@title"/>				<xsl:if test="siteMapNode">					<xsl:call-template name="map"/>				</xsl:if>			</a>		</li>	</xsl:template></xsl:stylesheet>

    ...and I then added the link to that doc inside of the XSLT doc that's calling it (aboutus.xsl), like this (without the HTML tags, since they're already called from the ASP.NET doc):

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:output method="xml" encoding="UTF-8" indent="yes"/>	<xsl:include href="siteMap.xsl"/><!-- this includes the sample file that generates the list -->	<xsl:template match="/"><!-- this can of course be anything you'd like -->				<div id="navigation">					<!--You can change the file's URI from here -->					<xsl:for-each select="document('http://localhost:1309/phase3/Web.sitemap')/">						<!-- if you want to use templates from the main file during the site map's generation, remove the select attribute below -->						<xsl:apply-templates select="siteMap"/>					</xsl:for-each>				</div>				<div id="content">					<xsl:apply-templates/>				</div>	</xsl:template></xsl:stylesheet>

    ...but I received this error message:Exception Details: System.Xml.XPath.XPathException: Expression must evaluate to a node-set.I checked, and it is pulling the correct file siteMap.xsl, but I'm still getting this error. At this point, I'm feeling very frustrated. Hopefully I'm making a stupid mistake that can easily be corrected.

  16. After further testing, I realized that the "title" and "description" data was actually not being pulled from the Web.sitemap doc, but the source XML doc aboutus.xml. All of the setups were just pulling all of the nodes from that source XML doc.So with your suggested code, I'm still not able to pull up any attributes from the Web.sitemap doc to use on the page. If you have any additional suggestions, they would be greatly appreciated. Thanks.

  17. Try it with method="html".I'm also wondering as to what code are you using to call the transformaiton. You might be assablying the things in an odd way.Also, the sample code I gave you MUST be used as included in a file like the later. If you'll be using it stand alone, you might need to change the match of the first template to "/siteMap" (note the leading slash).
    I changed the output from xml to html, and I changed the first template match from "siteMap" to "/siteMap", but I got the same result.As for the transformation method I'm using, I'm using the Master Page method like this:MasterPage.master:
    <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" Debug="True" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><body>	<form id="form1" runat="server">		<div id="wrapper">			<div id="screenmain_modules">				<!-- dynamic page title -->				<h1><asp:label id="lblPageTitle" runat="server" /></h1>				<br />				<asp:SiteMapPath ID="SiteMapPath1" runat="server"></asp:SiteMapPath>				<br />				<hr class="navyblueline" />				<br />				<asp:label id="lblPageDesc" runat="server" />				<br /><br />				<asp:Xml id="xslTransform_mc" runat="server"></asp:Xml>				<asp:contentplaceholder					id="MainColumn"					runat="server">				</asp:contentplaceholder>			</div><!-- end screenmain_modules -->		</div><!-- end wrapper -->	</form></body></html>

    MasterPage.master.vb:

    Partial Class MasterPage	Inherits System.Web.UI.MasterPage	Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)		'Assign page path to string value		Dim strPagePath = Request.ServerVariables("PATH_INFO")		'Assign full page path		Dim strFullPagePath = "c:\Documents and Settings\MYUSERNAME\My Documents\Visual Studio 2005\Projects" & strPagePath		'Assign path to FileInfo Class		Dim fi As FileInfo = New FileInfo(strFullPagePath)		Dim strPageId As String, strPathNoFileName As String		Dim strXMLPath_mc As String, strXSLPath_mc As String, strCSSPath As String		'Check if files exist		If Not fi.Exists Then			strPageId = "default"			strPathNoFileName = "http://localhost:1309/phase3"		Else			strPageId = fi.Name.Replace(fi.Extension, "") 'without extension			strPathNoFileName = strPagePath.Replace(fi.Name, "")			'Assign dynamic page paths			strXMLPath_mc = strPathNoFileName + "docs/xml/" & strPageId & ".xml" 'xml doc			strXSLPath_mc = strPathNoFileName + "docs/xslt/" & strPageId & ".xsl" 'xsl doc		End If		'Assign page-specific properties		lblPageTitle.Text = SiteMap.CurrentNode.Title 'Page title label		lblPageDesc.Text = SiteMap.CurrentNode.Description 'Page desc. label		'Assign maincolumn XML/XSLT transformation properties		xslTransform_mc.DocumentSource = strXMLPath_mc  'Ends up with: http://www.mysite.com/phase3/aboutus/docs/xml/aboutus.xml		xslTransform_mc.TransformSource = strXSLPath_mc 'Ends up with: http://www.mysite.com/phase3/aboutus/docs/xslt/aboutus.xsl"	End SubEnd Class

    aboutus.aspx:

    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="aboutus.aspx.vb" Inherits="aboutus_aboutus" title="About Us" %><asp:Content ID="Content2" ContentPlaceHolderID="MainColumn" Runat="Server"></asp:Content>

    aboutus.aspx.vb:

    Partial Class aboutus_aboutus	Inherits System.Web.UI.Page	'Nothing is here yetEnd Class

    Hope that information helps. Let me know if you see what I'm doing wrong. Thanks.

  18. I used your suggested code:

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/>	<xsl:template name="map" match="siteMap">		<ul>			<xsl:apply-templates/>		</ul>	</xsl:template>	<xsl:template match="siteMapNode">		<li>			<a id="{@id}" href="{@url}">				<xsl:if test="@description">					<xsl:attribute name="title"><xsl:value-of select="@description"/></xsl:attribute>				</xsl:if>				<xsl:value-of select="@title"/>				<xsl:if test="siteMapNode">					<xsl:call-template name="map"/>				</xsl:if>	</xsl:template></xsl:stylesheet>

    and I also added a closing </a> and </li> before the last closing </xsl:template> tag to make the XSLT well-formed. But it only produced output that contained the title and description attributes. No link was created, even though those properties were set within the XSLT doc, and no other attributes were displayed. This was the output:<?xml version="1.0" encoding="utf-8"?>About UsThis page contains basic information about us.The other 2 attributes (url and id) were not displayed. Of course the "id" attribute is a custom attribute that I added to the Web.sitemap doc.The above code produced the same thing as me simply doing this:
    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/><!-- PAGE-SPECIFIC VARIABLES --><xsl:variable name="websitemap" select="document('http://localhost:1309/phase3/Web.sitemap')" />	<xsl:template match="/">		<xsl:apply-templates select="*"/>		Link: <xsl:value-of select="$websitemap/siteMap/siteMapNode/siteMapNode[@id='aboutus']" /><br />	</xsl:template></xsl:stylesheet>

    So I'm really confused on why I'm having trouble pulling the individual attributes with your solution, and why either one of these solutions have the same output. If you could give me any further assistance, that would be great. Thanks for your help.

  19. I have a site that uses the Master Page method in ASP.NET, and it contains a Web.sitemap doc that contains all of the navigation for the site. The Web.sitemap doc is basically an XML doc, so I was hoping that I could pull data from it using the XSLT document method, like this:Web.sitemap:

    <?xml version="1.0" encoding="utf-8" ?><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >  <siteMapNode url="~/default.aspx" title="Home Page" id="default">	<siteMapNode url="~/aboutus/aboutus.aspx" title="About Us" description="This page contains basic information about us." id="aboutus" />  </siteMapNode></siteMap>

    XSLT doc:

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes"/><!-- PAGE-SPECIFIC VARIABLES --><xsl:variable name="websitemap" select="document('http://localhost:1309/phase3/Web.sitemap')" />	<xsl:template match="/">		Link: <xsl:value-of select="$websitemap/siteMap/siteMapNode/siteMapNode[@id='aboutus']" /><br />	</xsl:template></xsl:stylesheet>

    ...but it's not working. Is this setup possible? If so, what am I doing wrong? Thanks for any help.

  20. I'm still a newbie to this whole process, so please bear with me. I'm including all of the referenced code at the bottom of this post.I'm trying to work with example code (Listing 7.10) from an online version of the book "XML for ASP.NET - Chapter 7: XSLT and ASP.NET", which can be seen at http://www.topxml.com/dotnet/articles/xslt/default.asp.But when I converted the C# code to VB.NET using the following converter site: http://www.developerfusion.co.uk/utilities...csharptovb.aspx, and I ran the ASP.NET page from within Visual Web Developer 2k5 Express, I received this error message:Compiler Error Message: BC30260: 'btnSubmit' is already declared as 'Protected Dim WithEvents btnSubmit As System.Web.UI.WebControls.Button' in this class.Source Error:Line 17: Public Class XsltGolferLine 18: Inherits System.Web.UI.PageLine 19: Protected btnSubmit As System.Web.UI.WebControls.ButtonLine 20: Protected pnlSelectGolfer As System.Web.UI.WebControls.PanelLine 21: Protected pnlTransformation As System.Web.UI.WebControls.PanelI've tried to research the error message, but I can't find a solution. So if anyone can let me know what I'm doing wrong, that would be great. Thanks for any help.ASP.NET code - xsltGolfer.aspx

    <%@ Page Language="VB" CodeFile="xsltGolfer.aspx.vb" Inherits="TestBed.Chapter7.XsltGolfer" Debug="True" %><HTML>	<HEAD>		<style type="text/css">			.blackText {font-family:arial;color:#000000;} .largeYellowText 			{font-family:arial;font-size:18pt;color:#ffff00;} .largeBlackText 			{font-family:arial;font-size:14pt;color:#000000;} .borders {border-left:1px 			solid #000000;border-right:1px solid #000000; border-top:1px solid 			#000000;border-bottom:1px solid #000000;}		</style>	</HEAD>	<body>		<form method="post" runat="server">			<asp:Panel ID="pnlSelectGolfer" Runat="server">				<TABLE width=400 bgColor=#efefef border=0 class="borders">					<TR>						<TD bgColor=#02027a>							<SPAN style="FONT-SIZE: 14pt; COLOR: #ffffff; FONT-FAMILY: arial">								Select a Golfer by Name:							</SPAN>						</TD>					</TR>					<TR>						<TD>							<asp:DropDownList id=ddGolferName runat="server">							</asp:DropDownList>						</TD>					</TR>					<TR>						<TD>							 						</TD>					</TR>					<TR>						<TD>							<asp:Button id=btnSubmit runat="server" Text="Get Golfer!">							</asp:Button>						</TD>					</TR>				</TABLE>			</asp:Panel>			<asp:Panel ID="pnlTransformation" Runat="server" Visible="False">				<DIV id=divTransformation runat="server">				</DIV>				<P>					<asp:LinkButton id=lnkBack Runat="server" Text="Back"> Back</asp:LinkButton></P>			</asp:Panel>		</form>	</body></HTML>

    C# version - xsltGolfer.aspx.cs

    namespace TestBed.Chapter7{	using System;	using System.Collections;	using System.ComponentModel;	using System.Data;	using System.Drawing;	using System.Web;	using System.Web.SessionState;	using System.Web.UI;	using System.Web.UI.WebControls;	using System.Web.UI.HtmlControls;	using System.Xml;	using System.Xml.XPath;	using System.Xml.Xsl;	using System.IO;	using System.Text;	/// <summary>	///		Summary description for test.	/// </summary>	public class XsltGolfer : System.Web.UI.Page		{		protected System.Web.UI.WebControls.Button btnSubmit;		protected System.Web.UI.WebControls.Panel pnlSelectGolfer;		protected System.Web.UI.WebControls.Panel pnlTransformation;		protected System.Web.UI.WebControls.DropDownList ddGolferName;		protected System.Web.UI.WebControls.LinkButton lnkBack;		protected System.Web.UI.HtmlControls.HtmlGenericControl divTransformation;		private string xmlPath;			public XsltGolfer() 		{			Page.Init += new System.EventHandler(Page_Init);		}		protected void Page_Init(object sender, EventArgs e) 		{			xmlPath = Server.MapPath("listing7.1.xml");			InitializeComponent();		}		#region Web Form Designer generated code		/// <summary>		///	Required method for Designer support - do not modify		///	the contents of this method with the code editor.		/// </summary>		private void InitializeComponent()		{				this.lnkBack.Click += new System.EventHandler(this.lnkBack_Click);			this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);			this.Load += new System.EventHandler(this.Page_Load);		}		#endregion		protected void btnSubmit_Click(object sender, System.EventArgs e) {						string xslPath = Server.MapPath("xsltGolfer.xsl"); 			XmlTextReader xmlReader = null;			StringBuilder sb = new StringBuilder();			StringWriter sw = new StringWriter(sb);						try {				xmlReader = new XmlTextReader(xmlPath);							//Instantiate the XPathDocument Class				XPathDocument doc = new XPathDocument(xmlReader);							//Instantiate the XslTransform Classes				XslTransform transform = new XslTransform();				transform.Load(xslPath);				//Add Parameters				XsltArgumentList args = new XsltArgumentList();				args.AddParam("golferName","",this.ddGolferName.SelectedItem.Value);				//Call Transform() method				transform.Transform(doc, args, sw);				//Hide Panels				this.pnlSelectGolfer.Visible = false;				this.pnlTransformation.Visible = true;				this.divTransformation.InnerHtml = sb.ToString();			}			catch (Exception excp) {				Response.Write(excp.ToString());			}			finally {				xmlReader.Close();				sw.Close();			}		}private void Page_Load(object sender, System.EventArgs e) {	if (!Page.IsPostBack) {		FillDropDown("firstName");	}}		protected void lnkBack_Click(object sender, System.EventArgs e)		{			this.pnlSelectGolfer.Visible = true;			this.pnlTransformation.Visible = false;			FillDropDown("firstName");		}private void FillDropDown(string element) {	string name = "";	this.ddGolferName.Items.Clear();	System.Xml.XmlTextReader reader = new XmlTextReader(xmlPath);	object firstNameObj = reader.NameTable.Add("firstName");	while (reader.Read()) 	{		if (reader.Name.Equals(firstNameObj)) 		{			name = reader.ReadString();			ListItem item = new ListItem(name,name);			this.ddGolferName.Items.Add(item);		}	}	reader.Close();}	}}

    VB.NET verison - xsltGolfer.aspx.vb

    Imports System.TextImports System.IOImports System.Xml.XslImports System.Xml.XPathImports System.XmlImports System.Web.UI.HtmlControlsImports System.Web.UI.WebControlsImports System.Web.UIImports System.Web.SessionStateImports System.WebImports System.DrawingImports System.DataImports System.ComponentModelImports System.CollectionsImports SystemNamespace TestBed.Chapter7	Public Class XsltGolfer		Inherits System.Web.UI.Page		Protected btnSubmit As System.Web.UI.WebControls.Button		Protected pnlSelectGolfer As System.Web.UI.WebControls.Panel		Protected pnlTransformation As System.Web.UI.WebControls.Panel		Protected ddGolferName As System.Web.UI.WebControls.DropDownList		Protected lnkBack As System.Web.UI.WebControls.LinkButton		Protected divTransformation As System.Web.UI.HtmlControls.HtmlGenericControl		Private xmlPath As String		Public Sub New()			AddHandler Page.Init, AddressOf Page_Init		End Sub		Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)			xmlPath = Server.MapPath("listing7.1.xml")			InitializeComponent()		End Sub		Private Sub InitializeComponent()			AddHandler Me.lnkBack.Click, AddressOf Me.lnkBack_Click			AddHandler Me.btnSubmit.Click, AddressOf Me.btnSubmit_Click			AddHandler Me.Load, AddressOf Me.Page_Load		End Sub		Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)			Dim xslPath As String = Server.MapPath("xsltGolfer.xsl")			Dim xmlReader As XmlTextReader = Nothing			Dim sb As StringBuilder = New StringBuilder			Dim sw As StringWriter = New StringWriter(sb)			Try				xmlReader = New XmlTextReader(xmlPath)				Dim doc As XPathDocument = New XPathDocument(xmlReader)				Dim transform As XslTransform = New XslTransform				transform.Load(xslPath)				Dim args As XsltArgumentList = New XsltArgumentList				args.AddParam("golferName", "", Me.ddGolferName.SelectedItem.Value)				transform.Transform(doc, args, sw)				Me.pnlSelectGolfer.Visible = False				Me.pnlTransformation.Visible = True				Me.divTransformation.InnerHtml = sb.ToString			Catch excp As Exception				Response.Write(excp.ToString)			Finally				xmlReader.Close()				sw.Close()			End Try		End Sub		Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)			If Not Page.IsPostBack Then				FillDropDown("firstName")			End If		End Sub		Protected Sub lnkBack_Click(ByVal sender As Object, ByVal e As System.EventArgs)			Me.pnlSelectGolfer.Visible = True			Me.pnlTransformation.Visible = False			FillDropDown("firstName")		End Sub		Private Sub FillDropDown(ByVal element As String)			Dim name As String = ""			Me.ddGolferName.Items.Clear()			Dim reader As System.Xml.XmlTextReader = New XmlTextReader(xmlPath)			Dim firstNameObj As Object = reader.NameTable.Add("firstName")			While reader.Read				If reader.Name.Equals(firstNameObj) Then					name = reader.ReadString					Dim item As ListItem = New ListItem(name, name)					Me.ddGolferName.Items.Add(item)				End If			End While			reader.Close()		End Sub	End ClassEnd Namespace

  21. I wanted to let you know that I used some of your code and other code to come up with a working solution, and I'd like to post it for any others that may want to use it. So here it is:

    Dim strPagePath As String = Request.ServerVariables("PATH_INFO")Dim fi As FileInfo = New FileInfo(strPagePath)'Split page pathDim myArray = Split(strPagePath, "/") 'the delimiter is the slash'Declare array valuesDim i As IntegerFor i = 0 To UBound(myArray) 'the UBound function returns 3		Response.Write(myArray(i) & "<br />") 'testNext 'move on to the next value of i'Assign page path values based on number of directories pulledSelect Case UBound(myArray)		Case 0 'default				Response.Write("There are no directories and the user will be redirected to the home page.") 'test		Case 1				Response.Write("There is one directory.") 'test		Case 2				Response.Write("There are two directories.") 'test		Case 3				Response.Write("There are three directories.") 'testEnd Select'Pull and assign strPageId value from filepath'Dim strPageId = fi.Name 'with extensionDim strPageId = fi.Name.Replace(fi.Extension, "") 'without extension

    With this code I'm able to pull the page's full path, split the directories up, perform tasks based on the number of directories in the array, and pull the page name with or without the extension.I don't know if it will help anyone, but it never hurts. Thanks again for your help.

  22. Hello all,Before I received your replies, I received a reply yesterday from this forum: http://www.webdeveloper.com/forum/showthre...6352#post706352...and this is what I did with that suggestion:'Declare page pathDim strPagePath As String = Request.ServerVariables("PATH_INFO")Dim myArray = Split(strPagePath, "/") 'the delimiter is the slash'Display the split stringDim iFor i = 0 To UBound(myArray) 'the UBound function returns 3 Response.Write(myArray(i) & "<br>")Next 'move on to the next value of i This solution works, but I'd like to hear your opinions on whether or not it's the best and most-efficient solution when it comes to coding properly in ASP.NET/VB.NET. Thanks for your help and input.

  23. I have what's hopefully a pretty simple question about how to pull parts of a string into variables from within an ASP.NET code-behind doc:. I'm currently researching a site at http://www.aspmatrix.com/asp-net/string_cl...ples/index.aspx to see if I can figure this out on my own, but I thought I'd also check here for some direction. So here is what I have/need:1) Pull the page path:Dim strPagePath As String = Request.ServerVariables("PATH_INFO")2) There are three path options for an ASP.NET file on my site:/maindir/page.aspx/maindir/subdir1/page.aspx/maindir/subdir1/subdir2/page.aspx3) I need to pull up to 4 possible variables (see below). This is where I'm running into a question: How can I pull the following variables from the above path when I don't know whether or not the file will be in the main directory (maindir), sub directory 1 (subdir1), and/or sub directory 2 (subdir2) until after the page is requested by the user?Dim strMainDir As String = "maindir"Dim strSubDir1 As String = "subdir1"Dim strSubDir2 As String = "subdir2"Dim strPageId As String = "page"Thanks for any and all help.

  24. Well, you're kind'a right.XForms can use Schema data types to determine whether a certain user input is valid or not. The client itself can verify the data against the corresponding data type and decide what to do (refuse to send the form and/or display an error message, etc.). The server can use the EXACT same schema to verify that EXACT same data, ensuring security. If you want to change what's valid in your form, you wuld only have to edit the shcema file, instead of editing tons of both ASP and JS.
    Ok, that helps me to make more sense of the setup. I'll continue working on it, and I'll let you know of the outcome of that work. Thanks again for all of your thorough answers...it's greatly appreciated.
  25. Sorry. I had been very bussy this week, and there are very few people that look into the XSLT forum but me (and I'm not braggin unfrortunatly).XForms are a client side alternative of the simple HTML forms. In other words, they are processed on the client side. That said, you don't need any special server setup to produce XForms. The bad news of this is that the client needs a special setup. It needs a plug-in that differs from browser to browser to be exact.If you're VERY creative, you might be able to create an XSLT that will covert XForms to HTML forms+JS, but that's a lot of work.The other current solution is to use FormFaces. It's a JS library that turns XForms in HTML files into HTML forms+JS, but you must know HTML files having XForms become invalid because of that.As for XSLT. It's not an obstacle at all. XSLT only takes one code and turns it into another one. So whatever you can write in an XML based file, you can also use as output (and input for that matter) for XSLT.
    Thanks for the reply boen_robot. It makes more sense to me now. Since I'm using a server-side solution of transforming XML & XSLT with ASP.NET, XForms obviously isn't the best solution for my site. I guess I'll have to work with a more basic forms solution.But I was wondering about using an XML schema for forms validation site-wide. If I created an XML schema for form uniformity, and I loaded it automatically for every form, could it display error messages upon an incorrectly-completed form as ASP could do? Or is the whole thing handled in a completely different way? I'm sorry to ask what are likely such easy-to-answer questions, but I'm still learning. So if you could let me know if this is possible, and point me in the right direction if it is, that would be great. Thanks for all of your help.
×
×
  • Create New...