Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

How to define the Actions element of the XML document

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone !
I am a beginner in XML, I want to know how to define the Actions element of the XML document by creating a complex XSD custom type that can check the Actions element ?
Can you help to validate my both xml with my XSD Schema

Thank in advance.

This is my XML





   


This is my XSD

 
Saloon Keeper
Posts: 12998
281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

What problem are you having?
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to be able to define the Actions element of the XML document by creating a complex XSD custom type that can check the Actions element of my XML.
But I can't do it.
 
Marshal
Posts: 26613
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you tried to do it. But you say you can't do it? You must have some reason for saying that. There could be all kinds of things going on, and it would help if you told us what they were.
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alric Rayan wrote:I would like to be able to define the Actions element of the XML document by creating a complex XSD custom type that can check the Actions element of my XML.
But I can't do it.



Sorry I'm a beginner in XML and I have some difficulties.
Here is what I did to validate my xml but it only validates my first xml and not both

Thank in advance

 
Paul Clapham
Marshal
Posts: 26613
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay... what makes you think it didn't validate both XMLs?
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Okay... what makes you think it didn't validate both XMLs?



Because I had an error on the reject element.
I managed to validate my two xml. My second problem is that I want to
define the Actions element of the XML document by creating a complex custom XSD type that can check the Actions element. For example using <xs:complexType name="ActionsType" > I don't know how to set it up
Thank in advance

 
Stephan van Hulst
Saloon Keeper
Posts: 12998
281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using "ref" everywhere? Instead of wrapping all your complex types in <xs:element>, declare your complex types directly in <xs:schema> and then use the "type" attribute rather than the "ref" attribute to type your child nodes.

You should have only one <xs:element> element directly in your <xs:schema>, which is the root element for your PurchaseOrder:

Change your XSD, post it here and tell us what problem you are facing afterwards.
 
Saloon Keeper
Posts: 23703
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pedantic twerp here. It's not an "XSD". That's just the standard filename extension for XML Schema files.
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there!
I'm back again, it took me a little while to redo my xsd. I have redone it but I have an error that I can't fix.




I encounter an error at this level in my xsd



This is the error I get

The content of the element 'Reject' is incomplete. Expected list of possible elements : 'Comment, User, Date'.



Thank you in advance
 
Stephan van Hulst
Saloon Keeper
Posts: 12998
281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why yes, you have an empty <Reject/> element in your XML, which doesn't conform to your new schema.

Why have you declared RejectOne and RejectTwo if you're not using them?
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Why yes, you have an empty <Reject/> element in your XML, which doesn't conform to your new schema.

Why have you declared RejectOne and RejectTwo if you're not using them?



It is normal that my xml has an empty reject. I have to validate two xml where one has an "empty reject" and the other one doesn't. I edited my XSD actually I was not using "rejectOne and rejectTwo".  I can't get them to validate .
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


sorry I didn't know that you can't edit an old post
 
Stephan van Hulst
Saloon Keeper
Posts: 12998
281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alric Rayan wrote:It is normal that my xml has an empty reject. I have to validate two xml where one has an "empty reject" and the other one doesn't.


Well, your schema doesn't reflect that it's allowed to have an empty Reject element. Update your schema to make the child elements of the Reject element optional.
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are my two XML

XML 1




XML 2


   
 
Stephan van Hulst
Saloon Keeper
Posts: 12998
281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, XML 1 is invalid according to your schema.
 
Alric Rayan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Yes, XML 1 is invalid according to your schema.


exactly can you help me to get both validated. I am stuck on this part
 
Sheriff
Posts: 16252
271
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alric Rayan wrote:

Stephan van Hulst wrote:Yes, XML 1 is invalid according to your schema.


exactly can you help me to get both validated. I am stuck on this part



Stephan already gave you his suggestion: make the Date, Comment, and User elements under Reject optional elements.

Google for xml optional elements
 
Alric Rayan
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:

Alric Rayan wrote:

Stephan van Hulst wrote:Yes, XML 1 is invalid according to your schema.


exactly can you help me to get both validated. I am stuck on this part



Stephan already gave you his suggestion: make the Date, Comment, and User elements under Reject optional elements.

Google for xml optional elements



Thank you so much, it's work.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic