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

📄 sdo-das-xml.examples.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 4 页
字号:
     schema file,     where there are three distinct pieces of information.     For illustration, here again are the first few lines of the      letter.xsd that we used above.    </p></div>        <div class="example-contents"><div class="cdata"><pre>&lt;xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;            xmlns:letter=&quot;http://letterSchema&quot;            targetNamespace=&quot;http://letterSchema&quot;&gt;              &lt;xsd:element name=&quot;letters&quot; type=&quot;letter:FormLetter&quot;/&gt;    &lt;xsd:complexType name=&quot;FormLetter&quot; mixed=&quot;true&quot;&gt;    .../...</pre></div>    </div>    <div class="example-contents"><p>    The three important values are:        <ul class="itemizedlist">     <li class="listitem">      <p class="para">       <var class="varname">letters</var>, the name of the document element      </p>     </li>     <li class="listitem">      <p class="para">       <var class="varname">FormLetter</var>, the name of the complex type of the document element.       This is also the name of the SDO type of the root data object.      </p>     </li>     <li class="listitem">      <p class="para">       <var class="varname">http://letterSchema</var>, the namespace to which the document element belongs.       This is also the namespaceURI of the SDO type of the root data object.      </p>     </li>    </ul>    It is part of the XML-SDO mapping rules that     when the SDO model is built from the schema file,    the typename and namespaceURI of the SDO types for the root element    are taken    from those of the complex type of the document element, where it exists.    Hence in this example the typename of the root data object is FormLetter.    In the event that there is no separate complex type definition    for the document element, when the the type is defined inline and is     anonymous,     the SDO type name will be the same as the element name.    </p></div>      <div class="example-contents"><p>    The following program loads the letter document and checks the     return values from each of the four calls.    </p></div>     <div class="example-contents">     <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Finding&nbsp;out&nbsp;what&nbsp;you&nbsp;can&nbsp;about&nbsp;the&nbsp;document&nbsp;and&nbsp;document&nbsp;element<br />&nbsp;*&nbsp;This&nbsp;can&nbsp;be&nbsp;quite&nbsp;hard&nbsp;to&nbsp;understand&nbsp;because&nbsp;there&nbsp;are&nbsp;four&nbsp;calls<br />&nbsp;*&nbsp;Two&nbsp;calls&nbsp;are&nbsp;made&nbsp;against&nbsp;the&nbsp;document<br />&nbsp;*&nbsp;Two&nbsp;calls&nbsp;are&nbsp;made&nbsp;against&nbsp;the&nbsp;root&nbsp;data&nbsp;object&nbsp;and&nbsp;its&nbsp;model<br />&nbsp;*&nbsp;Because&nbsp;of&nbsp;the&nbsp;SDO-XML&nbsp;mapping&nbsp;rules&nbsp;and&nbsp;how&nbsp;the&nbsp;SDO&nbsp;model&nbsp;is&nbsp;derived<br />&nbsp;*&nbsp;from&nbsp;the&nbsp;XML&nbsp;model,&nbsp;only&nbsp;three&nbsp;possible&nbsp;values&nbsp;can&nbsp;come&nbsp;back&nbsp;from&nbsp;these&nbsp;four&nbsp;calls.<br />&nbsp;*&nbsp;Always,&nbsp;$document-&gt;getRootElementURI()&nbsp;==&nbsp;(type&nbsp;of&nbsp;root&nbsp;data&nbsp;object)-&gt;namespaceURI&nbsp;<br />&nbsp;*&nbsp;Essentially,&nbsp;it&nbsp;all&nbsp;comes&nbsp;form&nbsp;the&nbsp;first&nbsp;few&nbsp;lines&nbsp;of&nbsp;the&nbsp;xsd:<br />&nbsp;*&nbsp;&lt;xsd:schema&nbsp;xmlns:xsd="http://www.w3.org/2001/XMLSchema"<br />&nbsp;*&nbsp;&nbsp;&nbsp;xmlns:letter="http://letterSchema"<br />&nbsp;*&nbsp;&nbsp;&nbsp;targetNamespace="http://letterSchema"&gt;<br />&nbsp;*&nbsp;&nbsp;&nbsp;&lt;xsd:element&nbsp;name="letters"&nbsp;type="letter:FormLetter"/&gt;<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">(</span><span style="color: #DD0000">"letter.xsd"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$document&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loadFile</span><span style="color: #007700">(</span><span style="color: #DD0000">"letter.xml"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$root_do&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 /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;The&nbsp;"root&nbsp;element&nbsp;name"&nbsp;is&nbsp;the&nbsp;element&nbsp;name&nbsp;of&nbsp;the&nbsp;document&nbsp;element<br />&nbsp;*&nbsp;in&nbsp;this&nbsp;case&nbsp;'letters'<br />&nbsp;*&nbsp;This&nbsp;matches&nbsp;the&nbsp;'name'&nbsp;attribute&nbsp;of&nbsp;the&nbsp;document&nbsp;element&nbsp;in&nbsp;the&nbsp;xsd&nbsp;and&nbsp;matches<br />&nbsp;*&nbsp;the&nbsp;element&nbsp;name&nbsp;from&nbsp;the&nbsp;xml<br />&nbsp;*/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;document&nbsp;element&nbsp;name&nbsp;is&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">getRootElementName</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">assert</span><span style="color: #007700">(</span><span style="color: #0000BB">$document</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRootElementName</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #DD0000">'letters'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;a&nbsp;property&nbsp;of&nbsp;the&nbsp;document<br /><br />/**<br />&nbsp;*&nbsp;The&nbsp;"root&nbsp;element&nbsp;URI"&nbsp;is&nbsp;the&nbsp;namespace&nbsp;part&nbsp;of&nbsp;the&nbsp;element&nbsp;name&nbsp;of&nbsp;the&nbsp;document&nbsp;element<br />&nbsp;*&nbsp;in&nbsp;this&nbsp;case&nbsp;'http://letterSchema'&nbsp;since&nbsp;'letters'&nbsp;is&nbsp;in&nbsp;that&nbsp;namespace<br />&nbsp;*&nbsp;This&nbsp;is&nbsp;taken&nbsp;from&nbsp;the&nbsp;xsd&nbsp;and&nbsp;matches&nbsp;the&nbsp;namespace&nbsp;picked&nbsp;up&nbsp;from&nbsp;the&nbsp;xml<br />&nbsp;*/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;document&nbsp;element&nbsp;is&nbsp;in&nbsp;the&nbsp;namespace&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">getRootElementURI</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">assert</span><span style="color: #007700">(</span><span style="color: #0000BB">$document</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRootElementURI</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #DD0000">'http://letterSchema'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;a&nbsp;property&nbsp;of&nbsp;the&nbsp;document<br /><br />/**<br />&nbsp;*&nbsp;The&nbsp;type&nbsp;name&nbsp;is&nbsp;taken&nbsp;from&nbsp;the&nbsp;SDO&nbsp;model<br />&nbsp;*&nbsp;The&nbsp;XML-SDO&nbsp;mapping&nbsp;rules&nbsp;make&nbsp;this&nbsp;either:<br />&nbsp;*&nbsp;&nbsp;&nbsp;The&nbsp;name&nbsp;of&nbsp;the&nbsp;complexType&nbsp;if&nbsp;there&nbsp;is&nbsp;one&nbsp;(in&nbsp;this&nbsp;case&nbsp;there&nbsp;is)<br />&nbsp;*&nbsp;&nbsp;&nbsp;The&nbsp;document&nbsp;element&nbsp;name&nbsp;if&nbsp;there&nbsp;no&nbsp;complexType<br />&nbsp;*&nbsp;This&nbsp;is&nbsp;taken&nbsp;from&nbsp;the&nbsp;xsd&nbsp;<br />&nbsp;*/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;type&nbsp;name&nbsp;of&nbsp;the&nbsp;root&nbsp;data&nbsp;object&nbsp;is&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$root_do</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTypeName</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">assert</span><span style="color: #007700">(</span><span style="color: #0000BB">$root_do</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTypeName</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #DD0000">'FormLetter'</span><span style="color: #007700">);&nbsp;&nbsp;<br /><br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;The&nbsp;type's&nbsp;namespaceURI&nbsp;is&nbsp;taken&nbsp;from&nbsp;the&nbsp;SDO&nbsp;model<br />&nbsp;*&nbsp;The&nbsp;XML-SDO&nbsp;mapping&nbsp;rules&nbsp;ensure&nbsp;that&nbsp;this&nbsp;will&nbsp;always&nbsp;be&nbsp;the&nbsp;same&nbsp;as&nbsp;<br />&nbsp;*&nbsp;the&nbsp;namepace&nbsp;URI&nbsp;of&nbsp;the&nbsp;document&nbsp;element<br />&nbsp;*/<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;namespaceURI&nbsp;of&nbsp;the&nbsp;root&nbsp;data&nbsp;object&nbsp;is&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$root_do</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTypeNamespaceURI</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">assert</span><span style="color: #007700">(</span><span style="color: #0000BB">$root_do</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTypeNamespaceURI</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #DD0000">'http://letterSchema'</span><span style="color: #007700">);&nbsp;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>     The output from this program is as follows:   </p></div>   <div class="example-contents"><div class="cdata"><pre>The document element name is lettersThe document element is in the namespace http://letterSchemaThe type name of the root data object is FormLetterThe namespaceURI of the root data object is http://letterSchema</pre></div>   </div>       </div>      <div class="example">    <p><b>Example #6 Printing the SDO model</b></p>    <div class="example-contents"><p>     The XML DAS provides a simple means to see what types and properties      have been loaded. The php &quot;print&quot; or &quot;echo&quot; instruction will      print out the types and properties.     </p></div>    <div class="example-contents">     <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/**<br />&nbsp;*&nbsp;Illustrate&nbsp;printing&nbsp;out&nbsp;the&nbsp;model<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">(</span><span style="color: #DD0000">"letter.xsd"</span><span style="color: #007700">);<br />print&nbsp;</span><span style="color: #0000BB">$xmldas</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>     The output from this program is as follows:   </p></div>   <div class="example-contents"><div class="cdata"><pre>object(SDO_XML_DAS)#1 {18 types have been defined. The types and their properties are::1. commonj.sdo:BigDecimal2. commonj.sdo:BigInteger3. commonj.sdo:Boolean4. commonj.sdo:Byte5. commonj.sdo:Bytes6. commonj.sdo:ChangeSummary7. commonj.sdo:Character8. commonj.sdo:DataObject9. commonj.sdo:Date10. commonj.sdo:Double11. commonj.sdo:Float12. commonj.sdo:Integer13. commonj.sdo:Long14. commonj.sdo:Short15. commonj.sdo:String16. commonj.sdo:URI17. http://letterSchema:FormLetter    - date (commonj.sdo:String)    - firstName (commonj.sdo:String)    - lastName (commonj.sdo:String)18. http://letterSchema:RootType    - letters (http://letterSchema:FormLetter)</pre></div>   </div>   </div>   </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sdo-das-xml.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.sdo-das-xml.html">SDO DAS XML Functions</a></div> <div class="up"><a href="book.sdo-das-xml.html">SDO DAS XML</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

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