⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdo-das-xml.examples.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 4 页
字号:
       &lt;element name= &quot;name&quot; type=&quot;string&quot;/&gt;       &lt;element name= &quot;length&quot; type=&quot;positiveInteger&quot; /&gt;     &lt;/sequence&gt;   &lt;/complexType&gt;   &lt;complexType name=&quot;bearType&quot;&gt;     &lt;sequence&gt;       &lt;element name= &quot;name&quot; type=&quot;string&quot;/&gt;       &lt;element name= &quot;weight&quot; type=&quot;positiveInteger&quot; /&gt;     &lt;/sequence&gt;   &lt;/complexType&gt;   &lt;complexType name=&quot;pantherType&quot;&gt;     &lt;sequence&gt;       &lt;element name= &quot;name&quot; type=&quot;string&quot;/&gt;       &lt;element name= &quot;colour&quot; type=&quot;string&quot; /&gt;     &lt;/sequence&gt;   &lt;/complexType&gt;&lt;/schema&gt;</pre></div>    </div>   </p></div>        <div class="example-contents"><p>    Here is the example PHP code that uses these two schema files:   </p></div>      <div class="example-contents"><p>    <div class="example-contents">     <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Illustrate&nbsp;open&nbsp;types&nbsp;and&nbsp;the&nbsp;use&nbsp;of&nbsp;the&nbsp;addTypes()&nbsp;method<br />&nbsp;*/<br /><br /></span><span style="color: #0000BB">$xmldas&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">SDO_DAS_XML</span><span style="color: #007700">::</span><span style="color: #0000BB">create</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addTypes</span><span style="color: #007700">(</span><span style="color: #DD0000">"jungle.xsd"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;this&nbsp;is&nbsp;an&nbsp;open&nbsp;type&nbsp;i.e.&nbsp;the&nbsp;xsd&nbsp;specifies&nbsp;it&nbsp;can&nbsp;contain&nbsp;"any"&nbsp;type<br /></span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addTypes</span><span style="color: #007700">(</span><span style="color: #DD0000">'animalTypes.xsd'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$baloo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDataObject</span><span style="color: #007700">(</span><span style="color: #DD0000">''</span><span style="color: #007700">,</span><span style="color: #DD0000">'bearType'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$baloo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Baloo"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$baloo</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">weight&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">800</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$bagheera&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDataObject</span><span style="color: #007700">(</span><span style="color: #DD0000">''</span><span style="color: #007700">,</span><span style="color: #DD0000">'pantherType'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$bagheera</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Bagheera"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$bagheera</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">colour&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'inky&nbsp;black'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$kaa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDataObject</span><span style="color: #007700">(</span><span style="color: #DD0000">''</span><span style="color: #007700">,</span><span style="color: #DD0000">'snakeType'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$kaa</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Kaa"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$kaa</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">length&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">25</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$document&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDocument</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$do&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$document</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRootDataObject</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$do</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bear&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$baloo</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$do</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">panther&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$bagheera</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$do</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">snake&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$kaa</span><span style="color: #007700">;<br /><br />print(</span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveString</span><span style="color: #007700">(</span><span style="color: #0000BB">$document</span><span style="color: #007700">,</span><span style="color: #0000BB">2</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </p></div>   <div class="example-contents"><p>    These two schema files are loaded into the XML DAS with first the     <b>create()</b>     and     <b>addTypes()</b>     methods.     The     <b>createDataObject()</b>     method is used to create three separate data objects.     In each case the namespaceURI and typename of the type are passed to the     <b>createDataObject()</b>     method: in this example the namespace URI is blank because no    namespace is used in the schema.     Once the three data objects - representing a bear, a panther and a snake -     have been created, a document object is created with the     <b>createDocument()</b>     method.     In this case there is no ambiguity about what the document element of the    document should be - as the second schema file only defines complex types,     the document element can only be the global     <var class="varname">jungle</var>     element defined     in the first schema.     This document will have a single root data object corresponding to an     empty document element <var class="varname">jungle</var>.     As this is an open type, properties can be added at will.     When the first assignment is made to <var class="varname">$do->bear</var>,    a property     <var class="varname">bear</var>     is added to the root data object:     likewise for the next two assignments.    When the document is written out by the     <b>saveString()</b>     method, the resulting document is:   </p></div>      <div class="example-contents"><p>    <div class="example-contents"><div class="cdata"><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;jungle xsi:type=&quot;jungle&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;  &lt;bear xsi:type=&quot;bearType&quot;&gt;    &lt;name&gt;Baloo&lt;/name&gt;    &lt;weight&gt;800&lt;/weight&gt;  &lt;/bear&gt;  &lt;panther xsi:type=&quot;pantherType&quot;&gt;    &lt;name&gt;Bagheera&lt;/name&gt;    &lt;colour&gt;inky black&lt;/colour&gt;  &lt;/panther&gt;  &lt;snake xsi:type=&quot;snakeType&quot;&gt;    &lt;name&gt;Kaa&lt;/name&gt;    &lt;length&gt;25&lt;/length&gt;  &lt;/snake&gt;&lt;/jungle&gt;</pre></div>    </div>   </p></div>          </div>   <div class="example">    <p><b>Example #5 Finding out what you can from the document</b></p>    <div class="example-contents"><p>     This example is intended to illustrate how you can find the      element name and      namespace of the document element from the XML Document object, and      the SDO type and namespace from the root data object of the XML data      object, and how they relate to one another.     This can be difficult to understand because there are four method calls:     two can be made against the Document object, and two that can be made      against any data object including the root data object.     Because of the rules that define how the SDO model is derived     from the XML model, when the data object concerned is the      root object that represents the document object for the document,      only three possible values can come back from these      four method calls.         </p></div>    <div class="example-contents"><p>     The two method calls that can be made against the document     are <b>getRootElementName()</b> and     <b>getRootEelementURI()</b>.     These return the element name and namespace of the document element,     respectively.     </p></div>        <div class="example-contents"><p>     The two method calls that can be made against any data object are      <b>getTypeName()</b>     and      <b>getTypeNamespaceURI()</b>.     These return the SDO type name and type namespace of the data object,      respectively.    </p></div>        <div class="example-contents"><p>     Always, calling <b>getRootElementURI()</b>     on the document object will return the same value as      calling <b>getNamespaceURI()</b> on the     root data object.      Essentially, the information is all derived from the first few lines of the 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -