Avatar of java domain
java domain
 asked on

Remove all the occurrence of a element from xsd using java

Can I get a sample java program which scans a folder for all the xsd and then

1. Removes the <choice> </choice> element from all the xsd
2. When there is a <choice> element could we check that the immediate parent element is <sequence> or not .
If its not there then wrap it by  <sequence> </sequence>  element.

I have attached the sample xsd .

Please help.
XMLJavaJava EEWeb Development

Avatar of undefined
Last Comment

8/22/2022 - Mon
Gertone (Geert Bormans)

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Gertone (Geert Bormans)

tested the XSLT and it does nicely waht you want by the way
(I think the smart way to perform such a task is using XSLT by the way)

Given your sample xsd, what would you want it to look like upon completion?
Gertone (Geert Bormans)

hi awking, the specification is in the question
- choice to sequence unless already wrapped in sequence then remove
that is exactly what the XSLT does
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

Geert Bormans,
>>the specification is in the question<<
It's just that the specifications weren't that clear to me. If the specifications were shown as follows:

Remove all <choice><\choice> elements with an immediate parent element of <sequence>.
Where there is no immediate parent element of <sequence>, convert any <choice> element to a <sequence> element.

I wouldn't have any issue. I just thought that seeing a final example of the output would confirm the requirements for me. I also think your xslt solution is the best way to go.

java domain,
Do you still need code which does the folder scanning to retrieve the xsds?