www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > XML

    XML Discussion and technical support for using and deploying XML applications and websites.

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 03-19-2009, 01:27 PM
    neuropunk neuropunk is offline
    Registered User
     
    Join Date: Mar 2009
    Posts: 5
    different roots in XML document

    Please, help me to understand what structure can have XML document which is described by this schema.

    schema:
    <schema xmlns="http://www.w3.org/2001/XMLSchema">
    <element name="A" />
    <element name="B" />
    </schema>

    Is it true that described XML document can have 2 possible roots?
    1) <A />
    2) <B />

    Or in other words: if schema doesn't have elements which have references to element "X" then this element "X" can be one of the roots of XML document. Is it true?
    Reply With Quote
      #2  
    Old 03-19-2009, 01:38 PM
    rpgfan3233 rpgfan3233 is offline
    Registered User
     
    Join Date: May 2008
    Posts: 382
    Technically, yes, an instance document can possibly have two root nodes using that schema. However, only one can be used at a time since a single document can only have a single root node.
    Reply With Quote
      #3  
    Old 03-19-2009, 03:20 PM
    neuropunk neuropunk is offline
    Registered User
     
    Join Date: Mar 2009
    Posts: 5
    Thank you for reply. It is resolved.

    Last edited by neuropunk; 03-19-2009 at 03:23 PM.
    Reply With Quote
      #4  
    Old 03-20-2009, 06:06 AM
    neuropunk neuropunk is offline
    Registered User
     
    Join Date: Mar 2009
    Posts: 5
    Want to make it in some way more difficult.

    schema A.xsd
    Code:
    <schema xmlns="http://www.w3.org/2001/XMLSchema"> 
       <import schemaLocation="В.xsd"/> 
       <element name="A" /> 
    </schema>
    schema B.xsd
    Code:
    <schema xmlns="http://www.w3.org/2001/XMLSchema"> 
       <element name="B" /> 
    </schema>
    Is it true in such case that described XML document can also have 2 possible roots? And what will change if we change instructions from import to include?
    Reply With Quote
      #5  
    Old 03-20-2009, 06:25 AM
    rpgfan3233 rpgfan3233 is offline
    Registered User
     
    Join Date: May 2008
    Posts: 382
    Actually, the first schema isn't usable without the namespace attribute. The import element requires a namespace at minimum with the schemaLocation being optional. If one schema uses the same namespace as another, the include element is a better choice, which requires the schemaLocation at minimum.

    The difference between import and include is the fact that the import element requires a namespace. import is used to include schemas or schema modules from other namespaces. include is used to include schemas or schema modules from the same namespace.
    Reply With Quote
      #6  
    Old 03-20-2009, 07:04 AM
    neuropunk neuropunk is offline
    Registered User
     
    Join Date: Mar 2009
    Posts: 5
    Thank you for corrections

    schema A.xsd
    Code:
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://targetNamespace.com"> 
       <import schemaLocation="В.xsd"/> 
       <element name="A" /> 
    </schema>
    schema B.xsd
    Code:
    <schema xmlns="http://www.w3.org/2001/XMLSchema"> 
       <element name="B" /> 
    </schema>
    Then lets assume that these 2 schemas have all required info. If there is no references to element "B" can be this imported element "B" one of the roots of XML document which is described by A.xsd schema?

    Last edited by neuropunk; 03-20-2009 at 07:13 AM.
    Reply With Quote
      #7  
    Old 03-22-2009, 04:45 AM
    neuropunk neuropunk is offline
    Registered User
     
    Join Date: Mar 2009
    Posts: 5
    I found out. Answer to previous question is yes: if there is no elements which have references to element "X", then this element can be one of the roots of described XML document, and it isn't important that this element "X" was originaly defined in root schema or in one of imported/included schemas.

    also I want to make small correction to previous post of rpgfan3233 regarding import and include instructions. you can look here for more details

    so it's resolved again
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:53 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.