I have the below code
BLOCK 1
</config>
<pd:inputBindings>
<xmlString>
<xsl:value-of select="$JMS-Queue-Receiver/ns:ActivityOutput/Body"/>
</xmlString>
</pd:inputBindings>
</pd:activity>
<pd:activity name="Checkpoint">
BLOCK 2
</config>
<pd:inputBindings>
<Telegence>
<xsl:for-each select="$Start/group/CHANGE_MDN">
<CHANGE_MDN>
<EVENT_TYPE>
i'm using the regex to select the from the BLOCK 2 ,
<pd:inputBindings>
<Telegence>
if we see the block 1 below we have the same set of items,
<pd:inputBindings>
<xmlString>
so i want to select the block 2 piece based on the next line , if we see the block 1 we have <xsl:value-of , so we should not select from the block 1. if we see the block 2 we have <xsl:for-each so that needs to be select.
So i want to select by negating the <xsl:value-of .
i tried with the below regex but it selects both the blocks.
<pd:inputBindings>[\r\n <]+[[:word:]]+>[\r\n <]+(?!xsl:value-of)
Related
current Output
<wd:GradeCode>CH_Service_Fly_test worker</wd:GradeCode>
<wd:GradeCode>CN_Dips_12 Engineer depart</wd:GradeCode>
Output needed
<wd:GradeCode>Service_Fl</wd:GradeCode>
<wd:GradeCode>Dips_12 En</wd:GradeCode>
Unfortunately little input. Which could probably work, would be the following function (depending on what you have in mind):
<!-- build a string after the first underline -->
<xsl:variable name="firstString">
<xsl:value-of select="substring-after(., '_')"/>
</xsl:variable>
<!-- limit the firstString to 10 digits -->
<xsl:value-of select="substring($firstString/text(),1,10)"/>
The pending to use for each item.
here is my current xslt:
<xsl:when test="position()=10">
This works, but i have 100 records so it only produces my neccessary html on the 10th record, and nothing more.
what i need now is a dynamic way of saying when is every ten positions. i imagine you could use modulus but im having difficulty getting that to work.
Ive tried:
<xsl:when test="position() mod 10">
Not sure what the solution is.
I think you want <xsl:when test="position() mod 10 = 0">.
i am having one issue in displaying description column data from the list in data view web part.Actually in my list i've a column named as Description type of this column is multiple line of text what i want if length of the text in description column is greater than 20 characters than display only 20 characters otherwise show all characters. I've written the following xslt to do that.
<xsl:choose>
<xsl:when test="string-length(#Description) > 20">
<xsl:value-of select="substring(#Description, 1, 20)" />...
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="#Description" disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
Same thing is working for the column whose type is single line of text,can anyone tell me how to achieve this for the column whose type is multiple line of text
What's the best way to select all text between 2 comment tags? E.g.
<!-- Text 1
Text 2
Text 3
-->
<\!--.* will capture <!-- Text 1 but not Text 2, Text 3, or -->
Edit
As per Basti M's answer, <\!--((?:.*\n)*)--> will select everything between the first <!-- and last -->. I.e. lines 1 to 11 below.
How would I modify this to select just lines within separate tags? i.e. lines 1 to 4:
1 <!-- Text 1 //First
2 Text 2
3 Text 3
4 -->
5
6 More text
7
8 <!-- Text 4
9 Text 5
10 Text 6
11 --> //Last
Depending on your underlying engine use the s-modifier (and add --> at the end of your expression.
This will make the . match newline-characters aswell.
If the s-flag is not available to you, you may use
<!--((?:.*\r?\n?)*)-->
Explanation:
<!-- #start of comment
( #start of capturing group
(?: #start of non-capturing group
.*\r?\n? #match every character including a line-break
)* #end of non-capturing group, repeated between zero and unlimited times
) #end of capturing group
--> #end of comment
To match multiple comment blocks you can use
/(?:<!--((?:.*?\r?\n?)*)-->)+/g
Demo # Regex101
Use the s modifier to match new lines. E.g.:
/<!--(.*)-->/s
Demo: http://regex101.com/r/lH0jK9
Regex is not the right tool to parse html or xml, use a proper parser, I use xpath here :
$ cat file.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<test>
<!-- Text 1
Text 2
Text 3
-->
</test>
The test :
$ xmllint --xpath '/test/comment()' file.xml
<!-- Text 1
Text 2
Text 3
-->
If you parse html, use the --html switch.
What's the best way to select all text between 2 comment tags? E.g.
<!-- Text 1
Text 2
Text 3
-->
<\!--.* will capture <!-- Text 1 but not Text 2, Text 3, or -->
Edit
As per Basti M's answer, <\!--((?:.*\n)*)--> will select everything between the first <!-- and last -->. I.e. lines 1 to 11 below.
How would I modify this to select just lines within separate tags? i.e. lines 1 to 4:
1 <!-- Text 1 //First
2 Text 2
3 Text 3
4 -->
5
6 More text
7
8 <!-- Text 4
9 Text 5
10 Text 6
11 --> //Last
Depending on your underlying engine use the s-modifier (and add --> at the end of your expression.
This will make the . match newline-characters aswell.
If the s-flag is not available to you, you may use
<!--((?:.*\r?\n?)*)-->
Explanation:
<!-- #start of comment
( #start of capturing group
(?: #start of non-capturing group
.*\r?\n? #match every character including a line-break
)* #end of non-capturing group, repeated between zero and unlimited times
) #end of capturing group
--> #end of comment
To match multiple comment blocks you can use
/(?:<!--((?:.*?\r?\n?)*)-->)+/g
Demo # Regex101
Use the s modifier to match new lines. E.g.:
/<!--(.*)-->/s
Demo: http://regex101.com/r/lH0jK9
Regex is not the right tool to parse html or xml, use a proper parser, I use xpath here :
$ cat file.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<test>
<!-- Text 1
Text 2
Text 3
-->
</test>
The test :
$ xmllint --xpath '/test/comment()' file.xml
<!-- Text 1
Text 2
Text 3
-->
If you parse html, use the --html switch.