how to get value of field with space in xsl file - xslt

Creating an ItemStyle XSL file for content query Webpart, i want to get value from the Pages library that inherits from Article Pages. this is OK with title or fields with no space. However, i seems not to work with field containing space, its display name is Article Date. I did try the following code:
<xsl:value-of select="#Article Date" />
Could you tell me, how could i do in such case? should i call external name of this field inside xsl file, like or other ways?

According to this page, the internal name for "Article Date" is ArticleStartDate. Try using that instead, and you may have more success.
<xsl:value-of select="#ArticleStartDate" />

Related

Can't read the XML node elements in ColdFusion

I'm trying to read some values from the XML file which I created, but it gives me the following error:
coldfusion.runtime.UndefinedElementException: Element MYXML.UPLOAD is undefined in XMLDOC.
Here is my code
<cffile action="read" file="#expandPath("./config.xml")#" variable="configuration" />
<cfset xmldoc = XmlParse(configuration) />
<div class="row"><cfoutput>#xmldoc.myxml.upload-file.size#</cfoutput></div>
Here is my config.xml
<myxml>
<upload-file>
<size>15</size>
<accepted-format>pdf</accepted-format>
</upload-file>
</myxml>
Can someone help me to figure out what is the error?
When I am printing the entire variable as <div class="row"><cfoutput>#xmldoc#</cfoutput></div> it is showing the values as
15 pdf
The problem is the hyphen - contained in the <upload-file> name within your XML. If you are in control of the XML contents the easiest fix will be to not use hyphens in your field names. If you cannot control the XML contents then you will need to do more to get around this issue.
Ben Nadel has a pretty good blog article in the topic - Accessing XML Nodes Having Names That Contain Dashes In ColdFusion
From that article:
To get ColdFusion to see the dash as part of the node name, we have to "escape" it, for lack of a better term. To do so, we either have to use array notation and define the node name as a quoted string; or, we have to use xmlSearch() where we can deal directly with the underlying document object model.
He goes on to give examples. As he states in that article, you can either quote the node name to access the data. Like...
<div class="row">
<cfoutput>#xmldoc.myxml["upload-file"].size#</cfoutput>
</div>
Or you can use the xmlSearch() function to parse the data for you. Note that this will return an array of the data. Like...
<cfset xmlarray = xmlSearch(xmldoc,"/myxml/upload-file/")>
<div class="row">
<cfoutput>#xmlarray[1].size#</cfoutput>
</div>
Both of these examples will output 15.
I created a gist for you to see these examples as well.

Remove specific title from TOC generated from wkhtmltopdf

I have several html files starting with a title and the author name, but I don't want them in the table of content. I used remove toc from toc in wkhtmltopdf to hard code the value of the h1/h2 to remove but I would like the xlst toc file to be independent of the name of the document and the author.
So I gave these specific titles a class attribute. The problem lies in the xlst filter, I didn't find a way to test or extract the class attribute.
Here is a part of the html file :
<h1 class="title">Me</h1>
<h2 class="author">My Title</h2>
Here is the xslt toc file part :
<xsl:template match="outline:item">
<li>
<xsl:if test="(#title!='') and (#title!='My little TOC')and (#class!='author')and (#class!='title')">
I'm a total newbie to xslt and don't know what outline:item really is, but it seems that it doesn't get the original class attribute. How could I get the job done ?
One simple solution is to use div tags instead of headings. In your CSS, make sure you specify display: block;.
if you run the
--dump-outline toc.xml
flag when you generate the pdf and look at the xml file you will see the xml nodes and attributes.
You can then test for either the title, page number, link and backlink the document. You can use these attributes for your if statment.
For example:
<xsl:if test="((#page!=1) and (#page!=2) and (#page!=5))">
blah blah blah
</xsl:if>
Note the brackets around the full test.
You can even then nest the if statements further if needed:
<xsl:if test="((#page!=1) and (#page!=2) and (#page!=5))">
<xsl:if test="(#title!='A title')">
more code
</xsl:if>
</xsl:if>

Umbraco copy-of not showing xml markup

I’m using Umbraco 4.7.0
My goal is to get the image path from a hard coded media node id of 4191. If I create a new macro with the code:
<xsl:copy-of select="umbraco.library:GetMedia(4191, false())"/>
I get the output:
/media/17675/my image.jpg50033618497jpg
I was expecting some well formed xml, however, it appears I’m missing all the tags. I therefore cannot reference the path for the image directly.
Am I missing something really simple here?
EDIT
I discovered how to get the raw xml output from my copy-of statement. I needed to wrap it in a <textarea> tag:
<textarea>
<xsl:copy-of select="umbraco.library:GetMedia(4191, false())"/>
</textarea>
This should do it:
<xsl:copy-of select="umbraco.library:GetMedia(4191, 0)/umbracoFile"/>
See also http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

Create custom ItemStyle template for SharePoint

I've created a custom ItemStyle_ContactDetails.xsl for a SharePoint 2010 content query web part, which points to this custom file via the ItemXslLink property. The web part will be filtered to display only one record for that department's contact info. The list it's reading has these columns:
#Title -- built-in SharePoint column
/dsQueryResponse/Rows/Row/#WorkAddress -- built-in SharePoint column
/dsQueryResponse/Rows/Row/#PrimaryNumber -- built-in SharePoint column
#EMail -- built-in SharePoint column
#Opening_x0020_Hours -- custom multi-line rich text column
The above names are what they're called in the Data View Web Part from another site. I had the following in that DVWP that worked for a local site:
<td colspan="2" class="ms-vb" style="text-align:center">
<b><xsl:value-of select="#Title"/></b><br></br>
<div style="margin-top:10px;"><xsl:value-of
select="/dsQueryResponse/Rows/Row/#WorkAddress"/>
(MAP)
</div>
Tel: <xsl:value-of select="/dsQueryResponse/Rows/Row/#PrimaryNumber"/><br></br>
<xsl:value-of select="#EMail"/>
<p><b>Opening Hours:</b></p>
<div style="position:relative; top:0; margin:0">
<xsl:value-of select="#Opening_x0020_Hours"
disable-output-escaping="yes"/>
</div>
</td>
How do I translate this to the custom ItemStyle_ContactDetails.xsl template? The user needs to see the info without having to click a link to get to it -- it's always going to be just one record for that department. Thanks.
Some serious trial-and-error yielded the result, along with this great article: http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx
Maybe others trying this same thing can find this useful: You can edit the custom XSL file on the server via SPDesigner, but you can't do the same with the web part and hope to have the changes immediately reflected. You must export the content query web part, then edit the file in Notepad, etc., to make your changes to the following 3 items:
Change the ItemXslLink to point to your custom XSL file:
<property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/ItemStyle_ContactDetails.xsl</property>
Change the ItemStyle item in the web part to reference your template name; the template name in the XSL file is ContactDetails:
<xsl:template name="ContactDetails" match="Row[#Style='ContactDetails']" mode="itemstyle">
So in your web part, you'd have this:
<property name="ItemStyle" type="string">ContactDetails</property>
Update the CommonViewFields to list your custom columns and their types:
<property name="CommonViewFields" type="string">WorkAddress, Text; EMail,Text; Contact_x0020_Department,Choice; Map,URL; Opening_x0020_Hours,Text; PrimaryNumber, Text</property>
Save the web part file and import (upload) it via the browser to your web part gallery. Each time you make changes to the web part, you'll want to do this; the XSL file can be edited and saved in SPDesigner and the changes reflect immediately in the browser.
Hope this helps someone who gets stuck like I was :)
Whenever I edit "CommonViewFields" in the Webpart, I cannot edit the Properties after inserting the Webpart because of Correlation Error.
I am using SP 2013 onprem. Do I really need to modify the Webpart ? Isn't it enough to create a custom itemstyle.xls ?
I am playing around now for days. Each days more I have to say - Sharepoint is a mess.

Sitecore: How do I retrieve the Mimetype / extension of a File field in XLST

I want to know either the mimetype or the extensions of a file field so that I can place an appropriate icon next to the download link.
I've been able to do this fine in .NET code. Should I just convert this rendering to a sublayout?
Adding a 3rd parameter to the sc:fld call lets you select a parameter from inside that field, you can then split the value on the '.' and go from there..
<xsl:variable name ="filename" select="sc:fld('file',.,'src')" />
Extension is : <xsl:value-of select="sc:SplitValue($filename,'.')[2]"/>
Hope this helps :D