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

  • SEARCH
  • Home
  • 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 1020677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:11:48+00:00 2026-05-16T11:11:48+00:00

I have a simple XML file, with 3 basic elements. The first one is

  • 0

I have a simple XML file, with 3 basic elements. The first one is required (minOccurs=1) and the second and third are optional. However, if the second element is used, then I would like the make the third one required. He’s the XML:

<?xml version="1.0" encoding="utf-8" ?>
<resultado>
        <consulta fonte="1" origem="Origem">0</consulta>
        <status resultado="REGULAR">0</status>
        <informacoes>
                <informacao tipo="CPF" dado="23340058865"></informacao>
                <informacao tipo="Nome" dado="Nome Titular CPF"></informacao>
                <informacao tipo="Endereco" dado="Rua Sem Fim, 48"></informacao>
                <informacao tipo="Cidade" dado="Fim do Mundo"></informacao>
                <informacao tipo="Estado" dado="TO"></informacao>
                <informacao tipo="Cep" dado="93847832"></informacao>
                <informacao tipo="Fone" dado="5938476354"></informacao>
        </informacoes>
</resultado>

If the status element is passed, then informacoes becomes a required element.
Below is my XSD:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="codigoresultado">
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="0"/>
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
            <xs:enumeration value="3"/>
            <xs:enumeration value="4"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="resultadoconsulta">
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="0"/>
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
            <xs:enumeration value="3"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="resultado">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="consulta" minOccurs="1" maxOccurs="1">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="resultadoconsulta">
                                <xs:attribute name="fonte" type="xs:integer" use="required" />
                                <xs:attribute name="origem" type="xs:string" use="required" />
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="status" minOccurs="0" maxOccurs="1">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="codigoresultado">
                                <xs:attribute name="resultado" type="xs:string" use="required" />
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="informacoes" minOccurs="0" >
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element minOccurs="1" maxOccurs="unbounded" name="informacao">
                                <xs:complexType>
                                    <xs:attribute name="tipo" type="xs:string" use="required" />
                                    <xs:attribute name="dado" type="xs:string" use="required" />
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Is that possible? If it is, how?
Thanks!

  • 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-16T11:11:48+00:00Added an answer on May 16, 2026 at 11:11 am

    The only way I would see is to bundle up these two elements into a <xs:sequence> of their own which would be optional.

    If it’s present, then both elements have to be present (or both can be left out).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 516k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The magical $() function of jQuery can take pretty much… May 16, 2026 at 6:47 pm
  • Editorial Team
    Editorial Team added an answer http://en.wikipedia.org/wiki/Geolocation_software Google uses IP Geolocation to get information from what… May 16, 2026 at 6:47 pm
  • Editorial Team
    Editorial Team added an answer Here's the implementation that I've come up with (while waiting… May 16, 2026 at 6:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a basic XML file that I load in my PHP using $xml
I have a simple XML file created in R that consists of the following
I'm trying to make a simple xml-editor for some basic but specific needs, the
My knowledge of xml and php is somewhat basic but have been able to
Currently the php framework I'm dealing with has a simple conf file with define
I'm learning javascript and jquery and have written a very basic script inside my
I'm working with XML and Python for the first time. The ultimate goal is
I got stuck with XML and Python. The task is simple but I couldn't
I'm trying to apply an xlst transformation using the following file. This is very
I have been given the tasks of speccing a mobile application, which will need

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.