w3pop.com :: ÍøÂçѧԺ :: Xquery :: XQuery ½éÉÜ
The best way to explain XQuery is to say that XQuery is to XML what SQL is to database tables.
¶ÔXQuery×îºÃµÄ½âÊÍÊÇ£ºXQueryÏ൱ÓÚXMLµÄ²éѯÓï¾ä£»XQueryÓëXMLÖ®¼äµÄ¹ØÏµ£¬¾ÍÈçͬSQLÓï¾äºÍÊý¾Ý¿â±í¡£
XQuery is designed to query XML data - not just XML files, but anything that can appear as XML, including databases.
XQueryÓÃÓÚ²éѯXMLÊý¾Ý —— ²»½ö½öÊÇXMLÎļþ£¬»¹°üÀ¨Ò»ÇÐÒÔXMLÐÎʽ³öÏֵĶ«Î÷£¬°üÀ¨Êý¾Ý¿â¡£
Before you continue you should have a basic understanding of the following:
ÔÚ¼ÌÐøÏÂÃæµÄѧϰ֮ǰ£¬ÄãÊ×ÏÈÓ¦¸Ã»ù±¾ÕÆÎÕÏÂÊö֪ʶ£º
If you want to study these subjects first, find the tutorials on our Home page.
Èç¹ûÄãÏ£ÍûÏÈѧϰÉÏÊö֪ʶ£¬Çë¿´ÎÒÃǵĽ̳ÌÖ÷Ò³¡£
XQuery is a language for finding and extracting elements and attributes from XML documents.
XQueryÊÇÓÃÓÚ´ÓXMLÎĵµÖвéÕÒºÍÌáÈ¡ÔªËØºÍÊôÐÔµÄÓïÑÔ¡£
Here is an example of a question that XQuery could solve:
ÏÂÃæÊÇÒ»¸ö¹ØÓÚXQueryËùÄܽâ¾öµÄÎÊÌâµÄ°¸Àý£º
"Select all CD records with a price less than $10 from the CD collection stored in the XML document called cd_catalog.xml".
´Ó´æ´¢ÔÚÃûΪ “cd_catalog.xml” µÄXMLÎĵµÄÚµÄCD¼¯ÖÐÑ¡ÔñËùÓм۸ñµÍÓÚ10ÃÀÔªµÄCD³ªÆ¬¡£
XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators. If you have already studied XPath you will have no problems with understanding XQuery.
XQuery 1.0 ºÍ XPath 2.0 ¾ßÓÐÏàͬµÄÊý¾ÝÄ£ÐͲ¢Ö§³ÖÏàͬµÄº¯ÊýºÍ²Ù×÷·û¡£Èç¹ûÄãÒÑ¾ÕÆÎÕÁËXPathµÄÏà¹ØÖªÊ¶£¬ÄÇô£¬Àí½âXQuery¾Í²»³ÉÎÊÌâÁË¡£
You can read more about XPath in our XPath Tutorial.
Äã¿ÉÒÔ ÔÚÎÒÃǵÄXPath ½Ì³ÌÖÐѧϰ¸ü¶à¹ØÓÚXPathµÄ֪ʶ¡£
XQuery can be used to:
XQuery ¿ÉÓÃÓÚÏÂÊö²Ù×÷£º
XQuery is compatible with several W3C standards, such as XML, Namespaces, XSLT, XPath, and XML Schema.
XQueryºÍһЩW3CµÄ±ê×¼ÊÇÏ໥ÎǺϵģ¬ÀýÈ磺XML¡¢Namespaces [ÃüÃû¿Õ¼ä]¡¢XSLT¡¢XPath ºÍ XML Schema¡£
However, XQuery 1.0 is not yet a W3C Recommendation (XQuery is a Working Draft). Hopefully it will be a recommendation in the near future.
È»¶ø£¬XQuery 1.0 ²¢²»ÊÇW3CµÄÍÆ¼ö±ê×¼£¨XQuery ½öÊÇÒ»·Ý¹¤×÷²Ý°¸£©¡£ÏàÐÅÔÚ²»¾ÃµÄ½«À´£¬Ëü»á±ä³É W3C ÍÆ¼öµÄ±ê×¼°É¡£
ÆÀÂÛ (0)
All