- Dưới đây là hai thí dụ:. - author[1] Element author đ u tiên. - author[firstname][3] Element author th ba có m t Element ứ ộ firstname con.. - Một location path dùng một Axis để chỉ định mối liên hệ giữa các Nodes được chọn đối với context node. - ancestor:: T tiên c a context node. - Nh ng t tiên c a context node g m có cha, ông n i, ông c .v.v., do đó ữ ổ ủ ồ ộ ố. - ancestor:: axis luôn luôn k c root node tr khi chính context node là root ể ả ừ node.. - ancestor-or-self:: Chính context node và t tiên c a nó. - attribute:: Các Attributes c a context node. - N u context node không ph i là m t Element thì ch c ch n axis s tr ng ế ả ộ ắ ắ ẽ ố r ng. - child:: Con cái c a context node. - M t con là b t c node nào n m ngay d ộ ấ ứ ằ ướ i context node trong tree. - Tuy nhiên, Attribute hay Namespace nodes không đ ượ c xem là con cái c a ủ context node.. - descendant:: Con cháu c a context node. - ch a Attribute hay Namespace nodes. - following:: M i nodes hi n ra sau context node trên tree, không k con cháu, Attribute ọ ệ ể nodes, hay Namespace nodes.. - following-sibling:: M i nodes em (n m sau) context node. - following-sibling:: axis nói đ n ch nh ng Nodes con, c a cùng m t ế ỉ ữ ủ ộ Node cha, n m trên tree sau context node. - Axis không k các Nodes anh n m ằ ể ằ tr ướ c context node.. - N u context node là Attribute hay Namespace thì ế following-sibling::. - namespace:: Nh ng Namespace nodes c a context node. - M i namespace có m t namespace node trong scope (ph m vi ho t đ ng) ỗ ộ ạ ạ ộ c a context node. - N u context node không ph i là m t Element thì Axis s tr ng r ng. - Node cha là node n m ngay phía trên context node trên tree. - preceding:: M i nodes hi n ra tr ọ ệ ướ c context node trên tree, không k các nodes t tiên, ể ổ Attribute nodes, hay Namespace nodes.. - M t cách đ nh n di n ộ ể ậ ệ preceding:: axis là m i nodes đã k t thúc hoàn ọ ế toàn tr ướ c khi context node b t đ u. - preceding-sibling:: M i nodes anh (n m tr ọ ằ ướ c) context node.. - preceding-sibling:: axis nói đ n ch nh ng Nodes con, c a cùng m t ế ỉ ữ ủ ộ Node cha, n m trên tree tr ằ ướ c context node.. - N u context node là Attribute hay Namespace thì ế preceding-sibling::. - self:: Là chính context node.. - Thí dụ expression author/degree có nghĩa rằng hàm biến đổi Collection ra trị số Boolean sẽ có giá trị TRUE nếu hiện hữa một Element author có Element con tên degree.. - Nói một cách khác, cái expression book[author] có nghĩa là cho mỗi Element book tìm thấy, nó sẽ được thử xem có chứa một Element con tên author không. - có nghĩa rằng cho mỗi Element book tìm thấy, nó sẽ được thử xem có chứa một Element con tên author với trị số bằng Brown không.. - để khám current context node. - Thí dụ như, book. - 'Dreams'] có nghĩa rằng cho mỗi Element book tìm thấy trong current context, nó sẽ được thử xem có trị số bằng Dreams không. - Dưới đây là một ít thí dụ:. - book[excerpt] M i Element ọ book có ch a ít nh t m t Element ứ ấ ộ excerpt. - book[excerpt]/title M i Element ọ title n m trong nh ng Element ằ ữ book có ch a ít nh t ứ ấ m t Element ộ excerpt.. - book[excerpt]/author[degree] M i Element ọ author có ch a ít nh t m t Element ứ ấ ộ. - trong nh ng Elements ữ book có ch a ít nh t m t Element ứ ấ ộ. - book[author/degree] M i Element ọ book có ch a ít nh t m t Element ứ ấ ộ author m t Element ộ degree con.. - book[excerpt][title] M i Element ọ book có ch a ít nh t m t Element ứ ấ ộ excerpt m t Element ộ title.. - author[lastname = "Smith"] M i Element ọ author có ch a ít nh t m t Element ứ ấ ộ s b ng ố ằ Smith.. - "Smith"] M i Element ọ author có Element lastname con đ u tiên v i tr s ầ ớ ị ố b ng ằ Smith.. - "Harvard"] M i Element ọ degree, là con m t Element ộ author, và có m t ộ Attribute from v i tr s không ph i là ớ ị ố ả "Harvard". - author[lastname = /editor/lastname] M i Element ọ author có ch a m t Element ứ ộ lastname Element lastname là con c a root Element ủ editor.. - "John Hamilton"] M i Element ọ author có tr s string là ị ố John Hamilton. - Dưới đây là vài thí dụ:. - firstname | lastname M i Element ọ firstname và lastname trong current context.. - (bookstore/book | bookstore/magazine) M i Element ọ book hay magazine là con m t Element ộ. - book | book/author M i Element ọ book hay Element author là con nh ng Elements ữ book.. - (book | magazine)/price M i Element ọ price là con c a Element ủ book hay Element magazine.. - Thí dụ như, descendant::text() cho ta mọi text nodes là con cháu của context node, dù rằng loại node chính của con cháu context node là Element. - Node type Tr v ả ề Thí dụ. - ọ following::comment() ch n m i comment ọ ọ nodes hi n ra sau context node. - tr ướ c context node.. - processing-instruction() m i processing instruction node. - ọ self::processing instruction() ch n m i ọ ọ. - processing instruction nodes trong context node.. - ọ child::text() ch n m i text nodes là con c a ọ ọ ủ the context node.. - Thử Node nhắm vào loại Processing Instruction. - Một node test có thể chọn processing instruction thuộc loại nào, tức là chọn mục tiêu (target). - processing-instruction("target"). - Thí dụ node test sau đây trả về mọi processing instruction nodes có nhắc đến một XSL stylesheet trong tài liệu: . - /child::processing-instruction("xml-stylesheet"). - Thêm một số thí dụ Location Path. - ./author M i Element ọ author trong current context.. - author M i Element ọ author trong current context.. - //author M i Element ọ author trong tài li u. - book[/bookstore/@specialty = @style] M i Element ọ book có Attribute style v i value b ng value c a ớ ằ ủ Attribute specialty c a Document Element ủ bookstore. - bookstore//title M i Element ọ title m t hay nhi u b c th p h n, t c là con cháu ộ ề ậ ấ ơ ứ c a, Element ủ bookstore. - bookstore//book/excerpt//emph M i Element ọ emph b t c n i nào d ấ ứ ơ ướ i excerpt là con c a nh ng ủ ữ elements book , b t c n i nào d ấ ứ ơ ướ i element bookstore. - .//title M i Element ọ title m t hay nhi u b c th p h n current context ộ ề ậ ấ ơ node.. - author/* M i Element là con c a các elements con ọ ủ author.. - M i Element cháu c a current context node. - @style Attribute style c a current context node. - price/@exchange Attribute exchange c a nh ng Elements ủ ữ price trong current context, t c là nh ng Elements ứ ữ price c a current context node. - Expression n y đ ầ ượ c ch p nh n trong văn ph m c a XML ấ ậ ạ ủ Path Language, nh ng không th t s h p l . - book[@style] M i Element ọ book có Attribute style trong current context node.. - L u ý ph n n m trong ngo c vuông là đi u ki n c a Element ư ầ ằ ặ ề ệ ủ book. - book/@style Attribute style c a m i Element ủ ọ booktrong current context node.. - M i Attributes c a current context node. - author[1] Element author th nh t trong current context node. - author[firstname][3] Element author th ba có m t Element con ứ ộ firstname. - my:book Element book t namespace ừ my.
Xem thử không khả dụng, vui lòng xem tại trang nguồn hoặc xem
Tóm tắt