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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:07:09+00:00 2026-05-26T19:07:09+00:00

While generating XML files with SimpleXml, I got challengefull problem. I want to make

  • 0

While generating XML files with SimpleXml, I got challengefull problem.

I want to make dynamic xml output in the following way.

<process>
<sequence> ... </sequence>
<flow> ... </flow>
<sequence> ... </sequence>
<flow> ... </flow>
</process>

The question is How can I defined in the Schema using SimpleXMl?

Now, it looks in this way

@Root
public class Process {


    @ElementList(inline=true, required = false)
    private List<Sequences> sequence;

    @ElementList(inline=true, required = false)
    private List<Flows> flow;
    }

According this schema it always generates XML in following format:

<process>
<sequence> ... </sequence>
<sequence> ... </sequence>
<flow> ... </flow>
<flow> ... </flow>
</process>

What should I do?
Thank you.

  • 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-26T19:07:10+00:00Added an answer on May 26, 2026 at 7:07 pm

    This is how you need to use from the documentation:

    http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#scatter

    Good luck.


    Scattering inline element entries

    Elements that are scattered throughout an XML document can be collected by inline lists and inline maps. Simply provide an entry name for the XML element name the list or map is to collect and they will be extracted and placed in to the collection object. For example take the following XML element. It contains include and exclude XML elements which are in no specific order. Even though they are not in any order the deserialization process is able to gather the XML elements as thet are encountered.

    <fileSet path="/user/niall">
       <include pattern=".*.jar"/>
       <exclude pattern=".*.bak"/>
       <exclude pattern="~.*"/>
       <include pattern=".*.class"/>
       <exclude pattern="images/.*"/>
    </fileSet>
    

    In order to achieve this the following object can be used. This declares two inline collections which specify the name of the entry objects that they are collecting. If the entry attribute is not specified then the name of the object will be used instead.

    @Root
    public class FileSet {
    
       @ElementList(entry="include", inline=true)
       private List<Match> include;
    
       @ElementList(entry="exclude", inline=true)
       private List<Match> exclude;
    
       @Attribute
       private File path;
    
       private List<File> files;
    
       public FileSet() {
          this.files = new ArrayList<File>();
       }
    
       @Commit
       public void commit() {
          scan(path);
       }
    
       private void scan(File path) { 
          File[] list = path.listFiles();
    
          for(File file : list) {
             if(file.isDirectory()) {
                scan(path);
             } else {            
                if(matches(file)) {
                   files.add(file);
                }
             }
          }
       }
    
       private boolean matches(File file) {
          for(Match match : exclude) {
             if(match.matches(file)) {
                return false;
             }
          }
          for(Match match : include) {
             if(match.matches(file)) {
                return true;
             }
          }
          return false;
       }
    
       public List<File> getFiles() {
          return files;
       }
    
       @Root
       private static class Match {
    
          @Attribute            
          private String pattern;            
    
          public boolean matches(File file) {
             Stirng path = file.getPath();
    
             if(!file.isFile()) {
                return false;
             }
             return path.matches(pattern);         
          }         
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using XML Data Mapping and having a problem with generating complex types
We are getting the following error while generating a Jasper report when running our
I am working on a wordpress platform, while generating a mysql query I want
While generating charts using RS 2008 betas, RC0 and such., I never specified any
I need to play an MP3 in the background while generating animation. The audio
While going through university and from following the development of SO, I've heard a
In this case I have XML data source and external images files whole together
I've got an xml document that filled with people (parent node is students, and
I am generating XML in my c#, when I have few empty tags for
Background: I am generating pieces of a much larger XML document (HL7 CDA documents)

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.