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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:03:38+00:00 2026-05-25T15:03:38+00:00

Following file TPAExtensionsType.java I have generated from a XSD file. TPAExtensionsType.java /* * <p>The

  • 0

Following file TPAExtensionsType.java I have generated from a XSD file.

TPAExtensionsType.java

/* 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="TPA_Extensions_Type">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;any processContents='skip' maxOccurs="unbounded" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */ 
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TPA_Extensions_Type", propOrder = {
    "any"
})
@XmlRootElement 
public class TPAExtensionsType {

    @XmlAnyElement
    protected List<Element> any;

    /**
     * Gets the value of the any property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the any property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getAny().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Element }
     * 
     * 
     */
    public List<Element> getAny() {
    if (any == null) {
        any = new ArrayList<Element>();
    }
    return this.any;
    }

}

Following is the standalone application to marshall the above object to XML.

TestUtil.java

public class TestUtil {
    public static void main(String[] args) {
        TPAExtensionsType tpaExtensions = new TPAExtensionsType();
        Element consumerInfo = new DOMElement("ConsumerInfo");
        consumerInfo.setNodeValue("Some Info");
        tpaExtensions.getAny().add(consumerInfo);

        StringWriter sw  = new StringWriter();
        JAXBContext context;
        try {
            context = JAXBContext.newInstance(TPAExtensionsType.class);
            Marshaller marshaller = context.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
            marshaller.marshal(tpaExtensions, sw);
            System.out.println(sw.toString());
        } catch (JAXBException e) {
            e.printStackTrace();
        }

    }
}

Following is the output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tpaExtensionsType xmlns="SOME_NAMESPACE_ HERE">
    <ConsumerInfo xmlns="" xmlns:ns2="SOME_NAMESPACE_ HERE"/>
</tpaExtensionsType>

Problem I am facing:

The node ConsumerInfo has been created but its value is not visible in the generated XML though I have set its value in my standalone application above.Can anybody please help me getting this fixed and what is causing this problem?

  • 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-25T15:03:39+00:00Added an answer on May 25, 2026 at 3:03 pm

    Quoting the DOM spec on nodeValue(emphasis mine):

    The value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.

    If you scroll up a bit, you’ll see a table where it mentions that Element type nodes are defined with a null nodeValue. I guess that’s why it doesn’t show up in your XML, because setting it has no effect.

    Maybe you could use Node.setTextContent(String textContent)?

    Document doc = DocumentBuilderFactory.newInstance()
                      .newDocumentBuilder().newDocument();
    Element consumerInfo = doc.createElement("consumerInfo");
    consumerInfo.setTextContent("some info");
    doc.appendChild(consumerInfo);
    TPAExtensionsType tp = new TPAExtensionsType();
    tp.getAny().add((Element) doc.getFirstChild());
    
    JAXBContext jc = JAXBContext.newInstance(TPAExtensionsType.class);
    Marshaller marshaller = jc.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(tp, System.out); 
    

    Output

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <tpaExtensionsType>
        <consumerInfo>some info</consumerInfo>
    </tpaExtensionsType>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following file from the PARSEC opensource benchmarks, and I want to
I have the following text file content: <?php //================ Versions ================ $applicatoinversion = '1.2.3.40';
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If
I have the following file/line: pc=1 ct=1 av=112 cv=1100 cp=1700 rec=2 p=10001 g=0 a=0
I have the following file: abcde kwakwa <0x1A> line3 linllll Where <0x1A> represents a
I have the following file file: <html> <head> <title></title> <script type=text/javascript src=/Prototype.js></script> <script type=text/javascript>
I have the following file: <html> <head> <title></title> <link rel=css type=text/css href=/empty.css title=css />
I have the following file (above) which seems to be an Unix pipe alt
I have the following File object pointing to a directory via symbolic link, File
Hi I have the following file: $ cat file.txt col1 col2 col3 zz2 mm

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.