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 8281743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:08:20+00:00 2026-06-08T10:08:20+00:00

<complexType name=spThread> <sequence> <element name=SPThreadID type=int /> <element name=durtime minOccurs=0 default=0> <simpleType> <restriction base=int>

  • 0
<complexType name="spThread">
        <sequence>
            <element name="SPThreadID" type="int" />
            <element name="durtime" minOccurs="0" default="0">
                <simpleType>
                    <restriction base="int">
                        <minInclusive value="0" />
                    </restriction>
                </simpleType>
            </element>
            <element name="minexecutions" minOccurs="0" default="0">
                <simpleType>
                    <restriction base="int">
                        <minInclusive value="0" />
                    </restriction>
                </simpleType>
            </element>
            <element name="numThreads" type="int" />
            <element name="procedures" type="spm:procedure" minOccurs="1"
                maxOccurs="unbounded" />
        </sequence>
    </complexType>

i want to generate this type of .xsd file using java code..? How can i do that.?

Specially how to generate Simple type elements and put restrictions on it ?

  • 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-06-08T10:08:23+00:00Added an answer on June 8, 2026 at 10:08 am

    Instead of creating your own simple type to represent integers starting with 0, you could leverage the existing xs:nonNegativeInteger type. I’ll demonstrate with an example.

    SpThread

    You can use the @XmlSchemaType annotation to specify what type should be generated in the XML schema for a field/property.

    package forum11667335;
    
    import javax.xml.bind.annotation.XmlSchemaType;
    
    public class SpThread {
    
        private int durTime;
    
        @XmlSchemaType(name="nonNegativeInteger")
        public int getDurTime() {
            return durTime;
        }
    
        public void setDurTime(int durTime) {
            this.durTime = durTime;
        }
    
    }
    

    Demo

    You can use the generateSchema method on JAXBContext to generate an XML schema:

    package forum11667335;
    
    import java.io.IOException;
    import javax.xml.bind.*;
    import javax.xml.transform.Result;
    import javax.xml.transform.stream.StreamResult;
    
    public class Demo {
    
        public static void main(String[] args) throws Exception {
            JAXBContext jc = JAXBContext.newInstance(SpThread.class);
    
            jc.generateSchema(new SchemaOutputResolver() {
    
                @Override
                public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
                    StreamResult result = new StreamResult(System.out);
                    result.setSystemId(suggestedFileName);
                    return result;
                }
    
            });
        }
    
    }
    

    Output

    Below is the XML schema that was generated.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:complexType name="spThread">
        <xs:sequence>
          <xs:element name="durTime" type="xs:nonNegativeInteger"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XSD I have: <xs:complexType name=scheduleLocation> <xs:sequence> <xs:element name=arrivalTime type=hhmmss default=00:00:00 minOccurs=0/> <xs:element
I have this schema: <xs:complexType name=foo> <xs:sequence> <xs:element name=oneBar type=xs:string minOccurs=0/> <xs:element name=twoBar type=xs:string
Given this XML Schema snippet: <xs:element name=data> <xs:complexType> <xs:sequence> <xs:element name=param type=param minOccurs=0 maxOccurs=unbounded
I have the following xsd snippet: <xs:complexType name=HighSchoolType> <xs:sequence> <xs:element name=OrganizationName type=core:OrganizationNameType/> <xs:group ref=core:OrganizationIDGroup
I have a wsdl that contains the following complex type: <complexType name=OUTGROUP> <sequence> <element
I have an XML schema: <xsd:element name=Person> <xsd:complexType> <xsd:sequence> <xsd:element name=name type=xsd:string /> <xsd:element
Here is my code: xsdFile: <complexType name=Player> <sequence> <element name=Login type=string></element> <element name=Passwd type=string></element>
In an xsd file I have this element base type : <xs:complexType name=event abstract=true
The current XSD is : <xs:element name=Country> <xs:complexType> <xs:sequence> <xs:element name=code type=xs:string /> <xs:element
Web service wsdl contains following schema: <xs:complexType name=DocumentSearchInfo> <xs:sequence> ... <xs:element minOccurs=0 name=Industries nillable=true

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.