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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:42:50+00:00 2026-05-11T21:42:50+00:00

My xsd file contains: <xs:sequence> <xs:element name=Book> <xs:complexType> <xs:attribute name=author type=xs:string /> <xs:attribute name=title

  • 0

My xsd file contains:

                <xs:sequence>
                    <xs:element name="Book">
                        <xs:complexType>
                            <xs:attribute name="author" type="xs:string" />
                            <xs:attribute name="title" type="xs:string" />
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>

With xmlbeans, I can set the attributes easily using:

    Book book= books.addNewBook();
    book.setTitle("The Lady and a Little Dog");

I know that I can use newCursor() to set the content of the element, but is this the best way?

object.newCursor().setTextValue(builer.toString());
  • 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-11T21:42:50+00:00Added an answer on May 11, 2026 at 9:42 pm

    I don’t quite understand your question.

    I think your XSD will give you Java classes to produce XML like this:

    <book author="Fred" title="The Lady and a Little Dog" />
    

    Do you mean you want to set the “inner” text within an XML element, so you end up with XML like this?

    <book>
      <author>Fred</author>
      <title>The Lady and a Little Dog</title>
    </book>
    

    If so, change your XSD to this, to use nested elements rather than attributes:

    <xs:sequence>
        <xs:element name="Book">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="author" type="xs:string" />
                <xs:element name="title" type="xs:string" />
              </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
    

    Then you’ll simply be able to do:

    Book book= books.addNewBook();
    book.setAuthor("Fred");
    book.setTitle("The Lady and a Little Dog");
    

    UPDATE

    OK – I understand now.

    Try this:

    <xs:element name="Book"  minOccurs="0" maxOccurs="unbounded">
      <xs:complexType>
        <xs:simpleContent>
          <xs:extension base="xs:string">
            <xs:attribute name="author" type="xs:string" />
            <xs:attribute name="title" type="xs:string" />
          </xs:extension>
        </xs:simpleContent>
      </xs:complexType>    
    </xs:element>  
    

    And then:

        Book book1 = books.addNewBook();
        book1.setAuthor("Fred");
        book1.setTitle("The Lady and a Little Dog");
        book1.setStringValue("This is some text");
    
        Book book2 = books.addNewBook();
        book2.setAuthor("Jack");
        book2.setTitle("The Man and a Little Cat");
        book2.setStringValue("This is some more text");
    

    Which should give XML like this, which I think is what you want:

    <Book author="Fred" title="The Lady and a Little Dog">This is some text</Book>
    <Book author="Jack" title="The Man and a Little Cat">This is some more text</Book>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to read an XML file that contains the following element: <ho:CODED-TYPE ho:BASE-DATA-TYPE=A_UINT16
XML schema of XHTML Basic 1.1 ( xhtml-basic11-modules-1.xsd file ) contains such a redefine:
I have been provided an XSD and a sample Xml file that contains the
Suppose I have an XSD file having below lines of code; <xsd:simpleType name=test> <xsd:restriction
We have an XSD file along with some java src files. How can we
I have a simple doc.xml file which contains a single root element with a
I have WSDL file which contains: <wsdl:port name=NotificationConsumerSoapJms binding=tns_NotificationConsumer:NotificationConsumerSoapJmsBinding> <jms:address destinationStyle=topic jndiConnectionFactoryName=ConnectionFactory jndiDestinationName=dynamicTopics/test.DefaultTopic> <jms:JMSNamingProperty
I have an XSD file with an enumerated type. I'd like to create an
I have to create an xml file, that contains an element with attributes like:
I have an XSD file that contains the following... <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema elementFormDefault=qualified id=OTA2003A targetNamespace=http://www.opentravel.org/OTA/2003/05

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.