Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pulling first few characters of a textfiles into to a string

Status
Not open for further replies.

tiermann

Programmer
Nov 12, 2013
10
US
I am attempting to grab the first few characters into a string with in xslt. Is this possible? if so, can you help me :)
 
Do I understand correctly...

From XSLT, you want to pull in characters from a non-XML text file. Is that correct?

If so, what XSLT processor are you using?

Tom Morrison
Hill Country Software
 
I'm not sure. This is the header to the main xslt file.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns=" xmlns:xsl=" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:igxlib="urn:igxlibns"
exclude-result-prefixes="msxsl igxlib"
version="1.0">

<xsl:eek:utput method="xml"
version="1.0"
encoding="UTF-8"
indent="no"
omit-xml-declaration="yes" />
 
I'm trying to do this:
Code:
<xsl:variable name="theid1">../<xsl:value-of select="@URL"/>.xml</xsl:variable>
						<xsl:variable name="textonpage"><xsl:value-of select="document($theid1)" /></xsl:variable>

But it works on the CMS, but not in the browser
 
I'm getting this error in the browser. but not in the cms

Code:
Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[COMException (0x80004005): The system cannot locate the object specified.
]
   MSXML2.IXSLProcessor.transform() +0
   Ingeniux.Runtime.LegacyTransformationEngine.Transform(XNode sourceNode, String stylesheetPath, Boolean xslUpdated) +453
   Ingeniux.Runtime.DynamicTransformationEngine.Transform(CMSPageRequest pageRequest, String& contentType, String overrideStylesSheetFullPath, Boolean publishMode) +394
   Ingeniux.Runtime.Models.XsltTransformResult.ExecuteResult(ControllerContext context) in D:\dev\CMS\xpas_win_8_0\.NETRuntime\Dynamic_Site_Server\Models\XsltTransformResult.cs:38

[InvalidOperationException: Error occurred during XSLT transformation: The system cannot locate the object specified.
]
   Ingeniux.Runtime.Models.XsltTransformResult.ExecuteResult(ControllerContext context) in D:\dev\CMS\xpas_win_8_0\.NETRuntime\Dynamic_Site_Server\Models\XsltTransformResult.cs:50
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9042429
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016
 
Perhaps i'm doing it all wrong. This is what i'm doing (still an issue with the site map)

Code:
	<xsl:template match="SiteMapHTML">
		<xsl:variable name="breaktitle">Alumni</xsl:variable> <!-- Change this to break at a different point -->
		
		<table> 
			<tr>
				<td  width='50%' >
					<xsl:for-each select="//Navigation[@Name='HTMLSiteMap']//Page"> <!-- For each node -->
						
						<xsl:variable name="maintitle" select="@PageTitle"/> <!-- Saves title of page -->
						
						<xsl:if test="translate($maintitle, ' ', '')=translate($breaktitle, ' ', '')"> <!-- Strips the spaces and Checks if it is the same as the break title -->
							<xsl:value-of select="concat('&lt;', 'td', '&gt;')" 
								disable-output-escaping="yes" /> <!--  Adds a new colomn-->
						</xsl:if>
						<!-- This takes text off page.  Components have no text, so, if no text no show. :) -->
						<xsl:variable name="theid1">../<xsl:value-of select="@URL"/></xsl:variable>
						<xsl:variable name="textonpage"><xsl:value-of select="document($theid1)" /></xsl:variable>
						

						<xsl:variable name="depth" select="count(ancestor::*)"/>
						<xsl:if test="@Name!='' and 
							contains(@Schema, 'Component')!='true' and 
							contains(@Name, 'Component')!='true' and 
							contains(@Name, 'Box Stories')!='true' and
							$textonpage!=''"> <!--  Blank or component? -->
							
							<xsl:choose>
								<xsl:when test="$depth=2">  <!--  Neat it's a main node -->
									<li><a href="{@URL}"><xsl:value-of select="@Name"/></a></li>
								</xsl:when>
								<xsl:when test="$depth=3">  <!-- sub node -->
									<ul>
										<li><a href="{@URL}"><xsl:value-of select="@Name"/></a></li>
									</ul>
								</xsl:when>
							</xsl:choose>
						</xsl:if>
					</xsl:for-each>
				</td>
			</tr>
		</table>
	</xsl:template>
 
Ok, I had a few minutes to give this a look.

I am going to guess that this is the most important line of the diagnostic spew:
[tt][highlight #FCE94F]The system cannot locate the object specified.[/highlight][/tt]

The value of the URL used as the argument to the document() function is a relative reference; it begins with '[tt]..[/tt]'. This will be relative to the base URL for the transformation, i.e. the base URI for the stylesheet. Is this where the document is located?

This is merely a guess...

Tom Morrison
Hill Country Software
 
got it working!
turns out i had to define the variable "textonpage" outside the template
thank again man
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top