INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

pulling first few characters of a textfiles into to a string

pulling first few characters of a textfiles into to a string

pulling first few characters of a textfiles into to a string

(OP)
I am attempting to grab the first few characters into a string with in xslt. Is this possible? if so, can you help me :)

RE: pulling first few characters of a textfiles into to a string

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

RE: pulling first few characters of a textfiles into to a string

(OP)
I'm not sure. This is the header to the main xslt file.

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

<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:igxlib="urn:igxlibns"
exclude-result-prefixes="msxsl igxlib"
version="1.0">

<xsl:output method="xml"
version="1.0"
encoding="UTF-8"
indent="no"
omit-xml-declaration="yes" />

RE: pulling first few characters of a textfiles into to a string

(OP)
I'm trying to do this:

CODE --> xslt

<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

RE: pulling first few characters of a textfiles into to a string

(OP)
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 

RE: pulling first few characters of a textfiles into to a string

(OP)
Perhaps i'm doing it all wrong. This is what i'm doing (still an issue with the site map)

CODE --> xslt

<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('<', 'td', '>')" 
								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> 

RE: pulling first few characters of a textfiles into to a string

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:
The system cannot locate the object specified.

The value of the URL used as the argument to the document() function is a relative reference; it begins with '..'. 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

RE: pulling first few characters of a textfiles into to a string

(OP)
got it working!
turns out i had to define the variable "textonpage" outside the template
thank again man

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close