•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the XML, XSLT and XPATH section within the Software Development category of DaniWeb, a massive community of 456,577 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,629 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our XML, XSLT and XPATH advertiser: Programming Forums
Views: 6737 | Replies: 49
![]() |
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
SQL/XML scores over XQuery in below areas:
i) If your query need to return data from relational columns and from XML columns at the same time.
ii) If your query require full-text search conditions.
iii) If you want results returned as sets and missing XML elements represented with nulls.
iv) If you want to use parameter markers, because XQuery does not supports external parameters.
v) SQL/XML is good for applications that need to integrate relational and XML data. It provides the easiest means to join XML data and relational data.
vi) SQL/XML is good for grouping and aggregating of XML. The XQuery language does not provide an explicit group-by construct. Although grouping and aggregation can be expressed in XQuery using self-joins, it is quite awkward.
i) If your query need to return data from relational columns and from XML columns at the same time.
ii) If your query require full-text search conditions.
iii) If you want results returned as sets and missing XML elements represented with nulls.
iv) If you want to use parameter markers, because XQuery does not supports external parameters.
v) SQL/XML is good for applications that need to integrate relational and XML data. It provides the easiest means to join XML data and relational data.
vi) SQL/XML is good for grouping and aggregating of XML. The XQuery language does not provide an explicit group-by construct. Although grouping and aggregation can be expressed in XQuery using self-joins, it is quite awkward.
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
XSDs built-in datatypes are those which are defined below, and can be either primitive or derived.
Conceptually there is no difference between the built-in and derived datatypes.
Built-in primitive datatypes:
i) duration, dateTime, time, date, gYearMonth, gYear, gMonthDay, gDay, gMonth, boolean, base64Binary, hexBinary, float, double, anyURL, QName, NOTATION, string, decimal.
Built-in derived datatypes:
ii) normalizedString, integer, token, nonPositiveInteger, long, nonNegativeInteger, language, Name, NMTOKEN, negativeInteger, int, unsignedLong, positiveInteger, NCName, NMTOKENS, short, unsignedInt, ID, IDREF, ENTITY, IDREFS, ENTITIES, byte, unsignedShort, unsignedByte.
Each built-in datatype can be uniquely addressed via a URL reference constructed as below:
i) the base URL is the URL of the XML Schema namespace
ii) the fragment identifier is the name of the datatype or facet definition element
For example, to address the "int" datatype, the URL is:
http://www.w3.org/2001/XMLSchema#int
For example, to address the "maxInclusive" facet, the URL is:
http://www.w3.org/2001/XMLSchema#maxInclusive
Each facet usage in a built-in datatype definition can be uniquely addressed via a URL constructed as follows:
The fragment identifier is the name of the datatype, followed by a period (".") followed by the name of the facet
For example, to address the usage of the “maxInclusive” facet in the definition of “int”, the URL is:
http://www.w3.org/2001/XMLSchema#int.maxInclusive
You can read more at:
http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/
Conceptually there is no difference between the built-in and derived datatypes.
Built-in primitive datatypes:
i) duration, dateTime, time, date, gYearMonth, gYear, gMonthDay, gDay, gMonth, boolean, base64Binary, hexBinary, float, double, anyURL, QName, NOTATION, string, decimal.
Built-in derived datatypes:
ii) normalizedString, integer, token, nonPositiveInteger, long, nonNegativeInteger, language, Name, NMTOKEN, negativeInteger, int, unsignedLong, positiveInteger, NCName, NMTOKENS, short, unsignedInt, ID, IDREF, ENTITY, IDREFS, ENTITIES, byte, unsignedShort, unsignedByte.
Each built-in datatype can be uniquely addressed via a URL reference constructed as below:
i) the base URL is the URL of the XML Schema namespace
ii) the fragment identifier is the name of the datatype or facet definition element
For example, to address the "int" datatype, the URL is:
http://www.w3.org/2001/XMLSchema#int
For example, to address the "maxInclusive" facet, the URL is:
http://www.w3.org/2001/XMLSchema#maxInclusive
Each facet usage in a built-in datatype definition can be uniquely addressed via a URL constructed as follows:
The fragment identifier is the name of the datatype, followed by a period (".") followed by the name of the facet
For example, to address the usage of the “maxInclusive” facet in the definition of “int”, the URL is:
http://www.w3.org/2001/XMLSchema#int.maxInclusive
You can read more at:
http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
In this example XML Schema is written to validate the below XML document:
First we need to write a XML Schema Definition (XSD) file: electronicStockPrice.xsd
The next step is to register and complete registration of the XML schema as follows, providing the absolute path to the sqllib/samples/xml directory on your system and a URL com.mycompany.products :
REGISTER XMLSCHEMA http://wwww.mycompany.com/products FROM 'file:///<c:/sqllib/samples/xml> electronicStockPrice.xsd' AS com.mycompany.products COMPLETE
XML Syntax (Toggle Plain Text)
<electronicStockPrice> <name>electron tube light</name> <ask>102.54</ask> <bid>102.54</bid> <barcode>102.54</ barcode> </electronicStockPrice>
XML Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema targetNamespace="http://wwww.mycompany.com/products" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType name='BarcodeType'> <restriction base='string'> <pattern value='\d{3}-[A-Z]{2}'/> </restriction> </xsd:simpleType> <xsd:simpleType name="PriceType"> <xsd:restriction base="xsd:decimal"> <xsd:minInclusive value="0"/> <xsd:maxInclusive value="100000"/> <xsd:totalDigits value="9"/> <xsd:fractionDigits value="3"/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="StockPriceType"> <xsd:sequence> <xsd:element name="name" type="xsd:string"> <xsd:element name="ask" type="PriceType"> <xsd:element name="bid" type="PriceType"> <xsd:element name="barcode" type="BarcodeType"> </xsd:sequence> </xsd:complexType> <xsd:element name="electronicStockPrice" type="StockPriceType"> </xs:schema>
The next step is to register and complete registration of the XML schema as follows, providing the absolute path to the sqllib/samples/xml directory on your system and a URL com.mycompany.products :
REGISTER XMLSCHEMA http://wwww.mycompany.com/products FROM 'file:///<c:/sqllib/samples/xml> electronicStockPrice.xsd' AS com.mycompany.products COMPLETE
Last edited by peter_budo : Feb 6th, 2008 at 5:38 am. Reason: Please use [code] tags
•
•
Join Date: Oct 2007
Posts: 76
Reputation:
Rep Power: 2
Solved Threads: 0
This is a type of check constraint ("END_DATE > START_DATE") that cannot be validated using only resources of the XML schema. In order to solve this problem, the best alternative is to use the Schematron rule based language. The link between XML schema and the Schematron is done using the annotation/appinfo element.
In below example we can see the definition of END_DATE element with the integrity of Schematron notation, the check constraint is ("END_DATE > START_DATE").
The business rule is revealed with the use of an XPATH expression in the selected context END_DATE.
To validate the Schematron rule it is necessary to use an XSLT processor (for example, the saxon).
The list below shows the necessary steps in validating the Schematron rules using the saxon.
i) saxon new_project.sch XSD2SCHTRN.XSL > proj_sch.xsd
ii) saxon proj_sch.xsd schematron-basic.xsl > validator.xsl
iii) saxon project.xml validator.xsl > result2.txt
You can find more information at:
http://www.ibm.com/developerworks/db.../0209lima.html
In below example we can see the definition of END_DATE element with the integrity of Schematron notation, the check constraint is ("END_DATE > START_DATE").
<xsd:element name="END_DATE" type="DATE" nillable="true">
<xsd:annotation>
<xsd:appinfo>
<sch:pattern name="Check constraint end_date > start_date">
<sch:rule context="END_DATE">
<sch:assert test="( ./@xsi:nil='true' or (number(translate(./text(),'-','')) > number(translate(../START_DATE/text(),'-',''))))">
END_DATE must be greater than START_DATE.
</sch:assert>
</sch:rule>
</sch:pattern>
</xsd:appinfo>
</xsd:annotation>
</xsd:element> The business rule is revealed with the use of an XPATH expression in the selected context END_DATE.
To validate the Schematron rule it is necessary to use an XSLT processor (for example, the saxon).
The list below shows the necessary steps in validating the Schematron rules using the saxon.
i) saxon new_project.sch XSD2SCHTRN.XSL > proj_sch.xsd
ii) saxon proj_sch.xsd schematron-basic.xsl > validator.xsl
iii) saxon project.xml validator.xsl > result2.txt
You can find more information at:
http://www.ibm.com/developerworks/db.../0209lima.html
Last edited by peter_budo : Mar 10th, 2008 at 9:48 am. Reason: Keep It Organized - missing [code] tags
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 1
SQL-Structured Query Language
If you store such data in relational tables, you will have complicated relational schemas, which means you require many tables. Managing these tables can have overhead. The SQL query to access such data requires joining many tables.
SEO,Website development,Website designing
Office Space Delhi, Business Centre Delhi, Business Office Centre Delhi
If you store such data in relational tables, you will have complicated relational schemas, which means you require many tables. Managing these tables can have overhead. The SQL query to access such data requires joining many tables.
SEO,Website development,Website designing
Office Space Delhi, Business Centre Delhi, Business Office Centre Delhi
Last edited by ash05 : Jul 11th, 2008 at 3:19 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb XML, XSLT and XPATH Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Newbie question, schema, complex types and unordered multiple elemets (XML, XSLT and XPATH)
- XML Schema Question (RSS, Web Services and SOAP)
- WSDL file EDITING (VB.NET)
- SOAP n00b (RSS, Web Services and SOAP)
- XML Transformations (XML, XSLT and XPATH)
- automated database design (Database Design)
- IListSource does not contain any data sources (ASP.NET)
- parsing error (XML file-java-schema) (Java)
- Active Directory (Windows NT / 2000 / XP / 2003)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Bug in XPathAPI.selectSingleNode ???
- Next Thread: Java Script Menu with XML menu entries.


Linear Mode