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

XSLT - substring

XSLT - substring

(OP)
Good Day,

Not sure what the following does -

CODE

<xsl:value-of select="/article-doc[substring(@orig-obj-ref,1,4)='http']/@orig-obj-ref|/article-doc[substring(@orig-obj-ref,1,1)='/']/@orig-obj-ref"/>

Many thanks.

Regards,
Dan

RE: XSLT - substring

Select the value of the attribute orig-obj-ref from the root node named article-doc if (1) the value of orig-obj-ref begins with the letters 'http' or (2)  the value of orig-obj-ref begins with the character '/'.

substring(@orig-obj-ref,1,4) is selecting characters beginning at character 1 for 4 characters.

substring(@orig-obj-ref,1,1) is selecting characters beginning at character 1 for 1 character.

The square brackets are specifying a predicate (constraint) on the node.  

So, some examples:
<article-doc orig-obj-ref="http://blahblah">...</article-doc> would be selected.   The value returned would be http://blahblah.
<article-doc orig-obj-ref="/blahblah">...</article-doc> would be selected.  The value returned would be /blahblah.
<article-doc orig-obj-ref="blahblah">...</article-doc> would not be selected.




The '|' character is an operator in the expression.

XPath is fun!

Tom Morrison
Micro Focus

RE: XSLT - substring

(OP)
Many many thanks Tom.

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