XML
  Home arrow XML arrow Page 7 - XPointer Basics
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

XPointer Basics
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2001-12-12


    Table of Contents:
  • XPointer Basics
  • The Need For XPointer
  • Revolving Around An Axis
  • Proof Of The Pudding
  • A Fragmented View
  • A Range Of Options
  • Asymmetrically Yours
  • Linking Up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    XPointer Basics - Asymmetrically Yours
    ( Page 7 of 8 )

    The range() function is great for times when you need to define a range which begins and ends with the same element. However, for situations which require more asymmetric ranges, XPointer also offers the range-to() function, which allows link authors greater flexibility when defining ranges.

    The range-to() function creates a range beginning with the context node and ending with the location set specified as an argument to the range-to() function. For example, the following XPointer

    xpointer(id('67')/cast/range-to(id('67')/director))
    defines a range beginning at the opening "cast" element and ending at the closing "director" element.

    It's also possible to identify points and ranges within character data - the string-range() function scans a specified location for a match to a user-specified string, and returns a range containing the result. So, the following XPointer

    xpointer(string-range(//cast, "Patrick Stewart"))
    would return a range enclosing the string "Patrick Stewart" from the "cast" element.

    If the XML document above contained more than one "cast" element matching the specified string, the string-range() function would return multiple ranges, one for each match.

    It's possible to further constrain the range returned by specifying two additional arguments to the string-range() function - an offset to push forward the starting point of the range, and a length constraint to move back the ending point. So a modification of the XPointer above to

    xpointer(string-range(//cast, "Patrick Stewart", 9, 4))
    would return a range enclosing the substring "Stew".

    The string-range() function ignores embedded elements - which means that a change to the XML document above to read

    <?xml version="1.0"?> <movie id="67" genre="sci-fi"> <title>X-Men</title> <cast>Hugh<space />Jackman,<space />Patrick<space />Stewart<space />and<space />Ian<space />McKellen</cast> <director>Bryan Singer</director> <year>2000</year> <?play_trailer?> </movie>
    would not affect the XPointer at all.

    Since the string-range() function only returns string ranges, it follows that the start and end points of these returned ranges are always character-points, not node-points.

     
     
    >>> More XML Articles          >>> More By icarus, (c) Melonfire
     

       

    XML ARTICLES

    - Flex Array Collection Sort and Filtering
    - The Flex Tree Control
    - Flex List Controls
    - Working with Flex and Datagrids
    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT