{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

14xpath-2up - 14 XPath 07 Oct 2010 CSCC09F Programming on...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
14 XPath 07 Oct, 2010 CSCC09 Programming on the Web 1 14XPath CSCC09 Programming on the Web 1 XPath An expression language for selecting XML Document Components CSCC09F Programming on the Web 14XPath CSCC09 Programming on the Web 3 XPath boxshadowdwn XPath language provides a means of identifying a particular element, group of elements, text fragment, or other part of an XML document, that is modelled as a tree of nodes: circleshadowdwn root node boxshadowdwn implicit top-level element (the document root element is a child of this node, as are usually some PI nodes). circleshadowdwn element, attribute, namespace, processing instruction (PI), comment and text (maximal groupings of characters) nodes boxshadowdwn specified independent of XSL, intended for use with XSLT, as well as XQuery, XPointer and XLink boxshadowdwn in the case of XSLT, template rules use XPath patterns to define part(s) of the tree the template is to apply to ( match="…" ) transformations.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
14 XPath 07 Oct, 2010 CSCC09 Programming on the Web 2 14XPath CSCC09 Programming on the Web 4 XPath boxshadowdwn XPath – why should you care? boxshadowdwn XML technologies have huge and growing market presence (backed by W3C, and MS, IBM, Oracle, Cisco, Juniper, Sun, BMO, PWC, ...) boxshadowdwn Data representation and query: XQuery is designed to query anything that can appear as XML, including databases. boxshadowdwn Generic XML hyperlinks: XLink and XPointer define a standard for hyperlinks in XML documents. boxshadowdwn New generation of remote procedure calls and distributed documents based on XML (Web Services with SOAP, WSDL, XSchema) boxshadowdwn Data transformation: XSLT boxshadowdwn Web 2.0: jQuery can use XPath to select elements 14XPath CSCC09 Programming on the Web 5 XPath: motivational examples boxshadowdwn XPath excels in expressive ability to define complex subtree selections and relationships, e.g.: circleshadowdwn //CD // looks at entire tree, matches CD elements circleshadowdwn select only CD’s whose ARTIST child element content has text value “Bob Dylan” //CD[ARTIST="Bob Dylan"] circleshadowdwn selects all CD’s with id attribute value “cd12” – analogous to getElementById("cd12") in DOM //CD[@id="cd12"] circleshadowdwn now we want to select only the Bob Dylan CD’s costing more than $10.00 //CD[ARTIST="Bob Dylan" and PRICE>"10.00"] circleshadowdwn How would we select the YEAR of these Dylan CD’s? circleshadowdwn //CD[ARTIST="Bob Dylan" and PRICE>"10.00"]/YEAR boxshadowdwn Consider how you would write these expressions using the DOM addressing model (ugh!)
Image of page 2
14 XPath 07 Oct, 2010 CSCC09 Programming on the Web 3 14XPath CSCC09 Programming on the Web 7 XPath: motivational challenges boxshadowdwn How would you select the described subtrees using the XPath addressing model? circleshadowdwn select all CD’s with a price lower than the current node’s price circleshadowdwn //CD[price < current()/price] selects all CD’s with a price lower than the current node’s price circleshadowdwn select all CD elements that are first in a subtree list circleshadowdwn //CD[1] selects all CD elements that are first in a
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern