Você está na página 1de 7

Question # 01:

The purpose of an XML namespace is to allow the deployment of XML vocabularies (in
which element and attribute names are defined) in a global environment and to reduce the
risk of name collisions in a given document when vocabularies are combined. For example,
the MathML and SVG specifications both define the set element. Although XML data from
different formats such as MathML and SVG can be combined in a single document, in this
case there could be ambiguity about which set element was intended. XML namespaces
reduce the risk of name collisions by taking advantage of existing systems for allocating
globally scoped names: the URI system. When using XML namespaces, each local name in
an XML vocabulary is paired with a URI to distinguish the local name from local names in
other vocabularies. The use of URIs confers additional benefits. First, each URI/local name
pair can be mapped to another URI, grounding the terms of the vocabulary in the Web.
These terms may be important resources and thus it is appropriate to be able to associate
URIs with them... Another benefit of using URIs to build XML namespaces is that the
namespace URI can be used to identify an information resource that contains useful
information, machine-usable and/or human-usable, about terms in the namespace.
XML Best Practices:

Data modeling

XML data can be stored in multiple ways in SQL Server 2005 by using native xml data
type and XML shredded into tables. This topic provides guidelines for making the
appropriate choices for modeling your XML data. It also covers indexing XML data,
property promotion, and typing of XML instances.

Use

This section discusses use-related topics, such as loading XML data into the server and
type inference in query compilation. This section also explains and differentiates closely
related features and suggests appropriate use of these features. These are illustrated
with examples.
The Contains():
The contains() method uses the full-text index to subset the XML values that contain the
word "custom" anywhere in the document. The exist() clause ensures that the word
"custom" occurs in the title of a book.
A full-text search that uses contains() and XQuery contains() has different semantics. The
latter is a substring match and the former is a token match that uses stemming. Therefore,
if the search is for the string that has "run" in the title, the matches will include "run",

"runs", and "running", because both the full-text contains() and the Xquery contains() are
satisfied. However, the query does not match the word "customizable" in the title in that
the full-text contains() fails, but the Xquery contains () is satisfied. Generally, for pure
substring match, the full-text contains() clause should be removed.
Example

SELECT *
FROM T
WHERE CONTAINS(xCol,'custom')
AND xCol.exist('/book/title/text()[contains(.,"custom")]') =1

Question # 02:
DTDs:
XML provides an application independent way of sharing data. With a DTD, independent
groups of people can agree to use a common DTD for interchanging data. Your application
can use a standard DTD to verify that data that you receive from the outside world is valid.
You can also use a DTD to verify your own data.
Internal DTD
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to

(#PCDATA)>

<!ELEMENT from (#PCDATA)>


<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>

<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

External DTD
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

An XML Pipeline specifies a sequence of operations to be performed on a collection of XML


input documents. Pipelines take zero or more XML documents as their input and produce
zero or more XML documents as their output.
A pipeline consists of steps. Like pipelines, steps take zero or more XML documents as their
inputs and produce zero or more XML documents as their outputs. The inputs of a step
come from the web, from the pipeline document, from the inputs to the pipeline itself, or
from the outputs of other steps in the pipeline. The outputs from a step are consumed by
other steps, are outputs of the pipeline as a whole, or are discarded.
Example 1. A simple, linear XInclude/Validate pipeline
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
name="xinclude-and-validate"

version="1.0">
<p:input port="source" primary="true"/>
<p:input port="schemas" sequence="true"/>
<p:output port="result">
<p:pipe step="validated" port="result"/>
</p:output>

<p:xinclude name="included">
<p:input port="source">
<p:pipe step="xinclude-and-validate" port="source"/>
</p:input>
</p:xinclude>

<p:validate-with-xml-schema name="validated">
<p:input port="source">
<p:pipe step="included" port="result"/>
</p:input>
<p:input port="schema">
<p:pipe step="xinclude-and-validate" port="schemas"/>
</p:input>
</p:validate-with-xml-schema>
</p:declare-step>

Example 2. A simple, linear XInclude/Validate pipeline (simplified)


<p:pipeline xmlns:p="http://www.w3.org/ns/xproc"
name="xinclude-and-validate"
version="1.0">
<p:input port="schemas" sequence="true"/>

<p:xinclude/>
<p:validate-with-xml-schema>
<p:input port="schema">
<p:pipe step="xinclude-and-validate" port="schemas"/>
</p:input>
</p:validate-with-xml-schema>
</p:pipeline>

Você também pode gostar