0

Good Day, Sorry I'm still new in XML-XLST environment. I have a stylesheet and something like have an if-else statement which it will count the characters/string for that attributes if is > 100 it will move to the next line. Is it possible?

Here is the code:

<xsl:value-of select="/Orders/Remark/text()"/></font></td>

Code Updated:

<xsl:if test="string-length(@/Orders/Remark/text() &gt; 100">
<xsl:value-of select="/Orders/Remark/text()"/></font></td>
</xsl:if>

For More Explanation I really don't know how I will execute this codes, I only really want is if the of this <xsl:value-of select="/Orders/Remark/text()"/> if the strings is greater than 100, the exceeded (101 and so on...) strings will be go the next line.

Sample Picture:

This is the output right now that if the remarks string is greater 100.
enter image description here


What I want is something like this if Remarks string is greater 100 the next string will go to the next line.

enter image description here

Thank you.

Edmhar
  • 642
  • 1
  • 7
  • 24
  • What is the code posted supposed to do? I can't see any attempt to count and no attribute selector expression i.e `@attribute_name` involved there.. – har07 Mar 09 '16 at 02:24
  • @har07 I already updated the code, I don't have any idea how will execute the codes. What I really want is the value of `` if it is > 100 the other characters will go to the next line. Thank you. – Edmhar Mar 09 '16 at 02:30
  • @har07: Here sir. Thanks ` some attributes are here not connected to remarks... 12345678901231 ` – Edmhar Mar 09 '16 at 02:40
  • @har07, Thank you sir, but how can I code if the string count 105 and I want the 5 will go to the next line? Thanks again sir! – Edmhar Mar 09 '16 at 02:48
  • 2
    If you could post an [MCVE] i.e minimal XML sample, minimal XSLT attempt, and the actual output you want to get, it will be a lot easier to answer – har07 Mar 09 '16 at 02:53
  • @har07: Okay, I will wait sir. Thank you. – Edmhar Mar 09 '16 at 02:59
  • Waiting will not make your question any clearer... If I am guessing correctly, you want to split text into lines of maximum length. If so, see: http://stackoverflow.com/questions/34068953/xslt-split-string-on-every-nth-character-in-loop/34071485#34071485 – michael.hor257k Mar 09 '16 at 07:00

1 Answers1

1

If you just want to output value of /Orders/Remark/text() only if its length is over 100, then this can be done without xsl:if. You can use XPath predicate expression ([...]) to filter the text() nodes to those satisfy the minimum length requirement, for example :

<xsl:value-of select="/Orders/Remark/text()[string-length(.) &gt; 100]"/>
har07
  • 88,338
  • 12
  • 84
  • 137
  • So if the string-length is 101 it will not show up right? – Edmhar Mar 09 '16 at 03:43
  • The code currently do the opposite: the string will show up if its length is 101 or more. Try `<=` if you want otherwise – har07 Mar 09 '16 at 03:48
  • so if the code is `<= 100` then how can I go to the next line the remaining strings? thank you sir. – Edmhar Mar 09 '16 at 06:27
  • XSLT execution will go to the next line (in the same `xsl:template`) automatically after the code in this answer executed. So I don't understand what you asked in your comment. As I've suggested very early in the comment to your question, post [MCVE] and people will understand what you're trying to do precisely without you have to explain much. – har07 Mar 09 '16 at 06:34
  • I already update my thread with some picture. Thanks. – Edmhar Mar 09 '16 at 09:38