Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT - substring 1

Status
Not open for further replies.

ddrillich

Technical User
Jun 11, 2003
546
US
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
 
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=" would be selected. The value returned would be .
<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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top