How to obtain document library name from the URL - sharepoint

How to obtain document library name from the URL cqwp. For example,
http:///sites/site1/DocLib/Forms/AllItems.aspx
I know there is substring function with xsl
<xsl:param name="DocLibName">
select=substring(url) or whatever the code should be
</xsl:param>

The following code will give you the name of your document library from the URL you posted (or from any view in your document library)
String pattern = ".*/(?<listStaticName>.+)/[^\\.]+\\.aspx";
Regex regex = new Regex(pattern);
MatchCollection matches = regex.Matches(DefaultViewUrl);
String listStaticName = matches[0].Groups["listStaticName"].ToString();
You can use the method described in this article to call .NET code from XSL

Using the standard substring(string, int, int) function won't get you very far because I expect that the length of the document library name is unknown.
However, there are two functions that you can use in concert, substring-after(string, string) and substring-before(string, string). As long as your site names aren't "Forms", you can retrieve a partial string using substring-before([URL], "/Forms"). For the rest... it'll still be troublesome if you don't have immediate access to the site's name, but even removing that option it's still much easier than complex calculations in URL length. You'd basically have to continually perform substring-after([string], "/") until you pop off the last slash.

Some good Links.
http://msdn.microsoft.com/en-us/library/dd583143(office.11).aspx
Add these two line
<xsl:variable name="DocLibName" select="substring-before(substring-after($PageUrl, '/Forms/'), '/')" />
<xsl:param name="PageUrl"/>
set VIEWFLAG=1 (it should be in the properties windows)
Find this line and modify if you want Filter the webpart list
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
Change it to following
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[(#CustomerNo=$DocLibName)]"/>
You can use this to display
<xsl:value-of select="$DocLibName"> <br/>
<xsl:value-of select="$PageUrl"/><br/>

Related

How do I find tagname of node with xpath?

I have XPath expression //#*[contains(., 'multiDataSeries')] it is giving the nodes of which have attributes containing multiDataSeries. How do I find the just tag name of these nodes?
For example, it is giving the below results.
<processParameter name="multiDataSeries"> <lastModified isNull="true"/> </processParameter>
<processVariable name="multiDataSeriesP"> </processVariable>
<ns17:dataOutput xmlns:ns17="http://www.omg.org/spec/BPMN/20100524/MODEL" name="multiDataSeries" itemSubjectRef="itm.12.63a604e8-e026-4605-aae1-272b67822cc7" isCollection="true" id="2055.ad3b4033-e152-4060-871d-a360c3f21226"/>
<ns17:dataObject xmlns:ns17="http://www.omg.org/spec/BPMN/20100524/MODEL" itemSubjectRef="itm.12.63a604e8-e026-4605-aae1-272b67822cc7" isCollection="true" name="multiDataSeriesP" id="2056.401acef4-2a08-4d7a-a34f-5642cc73a329"> </ns17:dataObject>
My goal is to find just the tagNames in a list like below.
processParameter
processVariable
ns17:dataOutput
ns17:dataObjec
If - as it seems - you are limited to XSLT 1.0, you can use:
<xsl:for-each select="//*[#*[contains(., 'multiDataSeries')]]">
<xsl:value-of select="name()"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
Your current XPath addresses the attributes. I would change it to look for elements * and move the attribute criteria into a predicate, and then use the name() function to get the element's names:
//*[#*[contains(., 'multiDataSeries')]]/name()
As suggested by #MartinHonnen in the comments of MadsHansen answer and use Saxon-Js with node.js
And if your xml-results in your question are representative, meaning its's always the #name attribute and always starts with 'multiDataSeries', you could make the code perform better with:
//*[#name[starts-with(., 'multiDataSeries')]]/name()

XSLT: XPath 1.0 substring

Using XPath 1.0 in XSLT SharePoint 2013, I have two objectives:
To extract 'Library Name' from:
/path/to/library/could/be/any/length/Library Name/file.extension
To extract document id QYZM2HKWQCSZ-3-3 from the following:
http://sharepoint01/sites/temp/_layouts/15/DocIdRedir.aspx?ID=QYZM2HKWQCSZ-3-3, QYZM2HKWQCSZ-3-3
How to extract the desired strings?
OAN, for some reason Document Id column return the full blown path to the resource as opposed to Id only.
Any suggestions, how to get Id only (to avoid substring preprocessing)?
For (1), write a recursive template as follows. Pass the input string as a parameter.
(a) if not(contains(substring-after($input, '/'), '/')) then return substring-before($input, '/')
(b) otherwise, make a recursive call passing (substring-after($input, '/')) as the parameter.
(c) add some error-handling logic to make sure you terminate if the input string doesn't contain a '/'.
Not possible in plain XPath 1.0 if you cannot find any further pattern in the path.
It seems the pattern ?ID= is fixed, and also the colon following the ID. If so, you can use substring-after(substring-before(., ','), '?ID='). Replace the context . by some XPath expression selecting the string.

Casting string to path expression - Schematron

guys
I'm using schematron and I need to do the following:
Sometimes in the xml document I want to validate, there's elements like this:
<Var.X name="B">
For these elements (which name() has a dot in the middle) I need to see in the xml file if there's a diretory named Var with a child element with the attribute name = X (in this case), like this:
<Var>
<Obj name="X">
</Var>
I thought of transforming the name() of those objects to a string representing the path, so for this case particularly:
Var.X would be /*/Var/child::*[#name="X"]
Having this string, then I wanted to check if there's, actually, an element belonging to the path the string represents, but I can't cast the string to path type, and I don't even know if that's possible...
Is there a simpler way of doing this?
You can also use the name-function without an saxon-Extension!
<rule context="*[matches(name(),'\w\.\w')]">
<let name="beforePoint" value="substring-before(name(),'.')"/>
<let name="afterPoint" value="substring-after(name(),'.')"/>
<assert test="/*/*[name() = $beforePoint]/*[#name=$afterPoint]">error message</assert>
</rule>
I've realised that what I wanted to achieve is done with saxon:evaluate function... and I already achieved what I wanted

How do you prepare a string which contains both illegal characters AND hyperlinks for display in MXML in AS3?

i believe my question is quite simple:
I have a string, for example,
" this is a string containing silly characters like " and <<< and >>> and hey look a hyperlink http://www.google.com"
My question is how can I prepare this string to be displayed on an MXML view, using AS3?
any help is greatly appreciated!
http://forums.adobe.com/thread/756042
http://cookbooks.adobe.com/post_Hyperlink_Control-13867.html
These link gives you a information about how to create single link without any text like http://www.google.com/May these link will be helpfull to create a link!
But you problem looks different, so first you have to make html string with all of the text and where you want a link at that point you must put a <A> tag with required attribut and where you want a special character you must use its hex code or escape sequence of html like for & = &. my meaing is to say that make a html string without head tag. then give this string to <s:RichEditableText> see example.
First Way.
<s:RichEditableText>
<s:content>
<s:p>
Here is a link: <s:a href="www.google.com"</s:a>
</s:p>
</s:content>
</s:RichEditableText>
Second way.
//Your Actionscript code.
[Bindable] private var _testString:String= "<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="16" COLOR="#000000" LETTERSPACING="0" KERNING="0">" this is a string containing silly characters like <and > they look a hyperlink <FONT COLOR="#0000FF"><B><I><U>http://www.google.com</U></I></B></FONT>"</FONT></P></TEXTFORMAT>";
// your mxml content
<mx:RichTextEditor id="richEditableText1"
width="100%"
htmlText="{testString}"
height="100%"/>
Good Luck!

xsl substring after few chars but not cut the word

i want to call some substring text that i add in to virable
<xsl:variable name="substringbreakText">
<xsl:call-template name="insertBreaks">
<xsl:with-param name="subject" select="substring(PublicProfile/AboutMe,1,550)"/>
</xsl:call-template>
</xsl:variable>
and like go backwords on this text until i get white space or break.
so my point is to return string less then 550 chars but keep it look complate words
exmple:
thats my 550 chars:
"The image you see purports to depict Graham Bverly, Emeritus Professor of Academic Development in the Research Support Unit at Anglia ucla University, UK. He inquires into, and runs workshops on, writing for postgraduates and fellow academics.
But what messages does this portrait suggest to the reader? That Badley poses as an erudite thinker? That he seeks the light of truth? That he leans to the left? That he is, possibly, amused by such pretension? That he is sceptical? Perhaps. For ‘As a man is, so he sees’ (William Bleer).
Eme"
i want to cut the white space and "Eme" or cut the \r\n or in this string.
<xsl:value-of select="substring(#Description, 1, 500 + string-length(substring-before(substring(#Description, 501),' ')))" />
this could be changed to match a full stop or whatever to suit your needs :)
If you're in XSLT 1.0, finding the last space before the 550th character will involve recursion. Write a template which given a string:
(a) tests the last character of the string (using substring(s, string-length(s), 1))
(b) if it's a space, returns the string
(c) otherwise, calls itself passing substring(s, 1, string-length(s)-1) as the argument.
Pass this template substring(in, 1, 500) and it will return a string which ends with the last space in the supplied input.

Resources