Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7051397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:15:31+00:00 2026-05-28T03:15:31+00:00

I have an xml document that looks something like below (resources.xml), with a corresponding

  • 0

I have an xml document that looks something like below (resources.xml), with a corresponding xml-schema (resources.xsd). This xml document is manually maintained (i.e adding/removing/editing resource elements). In total there are maybe 500-1000 resource elements. Each resource can be of either variantX or variantY (in “real life”, there are a few more variants).

I would like to split up the xml document into several xml documents. One xml document for each variant (X and Y in this case), with a corresponding new xml-schemas. The xml schemas for each variant, should extend the original schema and only add a “hardcoded” (fixed?) value for it’s “variant” attribute.

Reason: To avoid repeating the “variant” attribute within each resource element.

Is this possible? What would the xml-schemas for each variant look like? What changes needs to be done in resources.xsd?

Any other suggestions are also welcomed 🙂

resources.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="resources.xsd">
        <resource name="res00" variant="X" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
        <resource name="res01" variant="X" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
        <resource name="res02" variant="Y" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
        <resource name="res03" variant="Y" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
    </resources>

resources.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:rb="http://example.org/resourcebase">

    <xs:complexType name="property">
        <xs:attribute name="name" type="xs:string" />
        <xs:attribute name="value" type="xs:string" />
    </xs:complexType>

    <xs:complexType name="resource">
        <xs:sequence>
            <xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required" />
        <xs:attribute name="variant" type="xs:string" use="required" />
    </xs:complexType>

    <xs:element name="resources">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="resource" type="resource" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Here’s how I picture this. One xml document for variant=X, which referrers to resourcesX.xsd. No need to add the “variant” attribute, as it is added by the referred resourcesX.xsd.

resourcesX.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="resourceX.xsd">
        <resource name="res00" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
        <resource name="res01" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
    </resources>

Another xml document for variant=Y, which referrers to resourcesY.xsd. No need to add the “variant” attribute, as it is added by the referred resourcesY.xsd.

resourcesY.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="resourceY.xsd">
        <resource name="res02" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
        <resource name="res03" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
    </resources>

Can resourceX.xsd and resourceY.xsd extend the resources.xsd? If so, what would they look like? any changes needed to be made in resources.xsd?

Thanks!
/Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:15:32+00:00Added an answer on May 28, 2026 at 3:15 am

    It sounds like your goal is to only have resources of a single variant in a particular file, in that case, instead of removing the variant attribute, would it make sense to move it to the root resources type? This would allow the document structure to retain the information about which variant is being represented, but also ensure that all of the resource elements in a particular file are associated with a particular variant. Something like:

    resources.xsd

    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
        <xs:complexType name="property">
            <xs:attribute name="name" type="xs:string" />
            <xs:attribute name="value" type="xs:string" />
        </xs:complexType>
    
        <xs:complexType name="resource">
            <xs:sequence>
                <xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="required" />
        </xs:complexType>
    
        <xs:element name="resources">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="resource" type="resource" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="variant" type="xs:string" use="required"/>
            </xs:complexType>
        </xs:element>
    </xs:schema>
    

    and instance document:

    resourceX.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="resources.xsd"
            variant="X">
        <resource name="res00" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
        <resource name="res01" >
            <property name="propA" value="..." />
            <property name="propB" value="..." />
        </resource>
    </resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright I have an xml document that looks something like this: <xml> <list> <partner>
I have an xml document with multiple nodes that looks something like this: <Result>
I have a XML document that looks something like this: <?xml version=1.0 encoding=UTF-8?> <citizen>
All, I have an XML document that looks something like this: <root> <profile> <childA>
I have an XML document that looks like this: <Data xmlns=http://www.domain.com/schema/data xmlns:dmd=http://www.domain.com/schema/data-metadata > <Something>...</Something>
I have an xml document that looks something like this <?xml version=1.0 encoding=UTF-8?> <mapPoints>
I have some XML that looks something like this: <Root> <Documents> <Document id=1/> </Documents>
I have an xml document that looks like this. <foo> <bar type=artist/> Bob Marley
Say I have a xml document that looks like this <foo> <bar id=9 />
I have an xml formatted document that looks like this: <?xml version=1.0 encoding=windows-1250?> <

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.