Hello,
How can I use XSD to ignore certain nodes of an XML document. Specifically,
we have an event that I want to define using XSD. I then want to validate
incoming XML events with that XSD. However, I want the payload section of
the event to be freeform and thus, *NOT* validated.
Is there a way to define a node (and all of it's contents) in an XSD so that
the validator requires that the node exists, but does not attempt to
validate the contents of the node?
Example of the event:
<MyEvent>
<Header attribute1="true" attribute2="23"/>
<Payload>
</Payload>
</MyEvent>
I would like to define an XSD that places strict validation on everything
you see in the above example. However, I do not want *ANY* validation on the
body of the <Payload> node.
Is this possible? We need this so that we can validate the format of the
incoming event, but at the same time allow for free form, dynamic content in
the payload.
Any assistance is appreciated.
--
Sincerely,
Drew Berkemeyer
Software Architect http://www.berkemeyer.com/ 8 2203
Drew Berkemeyer wrote: <MyEvent> <Header attribute1="true" attribute2="23"/> <Payload> </Payload> </MyEvent>
I would like to define an XSD that places strict validation on everything you see in the above example. However, I do not want *ANY* validation on the body of the <Payload> node.
You can use a definition alike
<xs:element name="Payload">
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded" />
</xs:sequence>
</xs:element>
see the xs:any definition in the W3X XML schema definition on http://www.w3.org/ for further options (to restrict contents to certain
namespaces for instance).
--
Martin Honnen http://JavaScript.FAQTs.com/
Thank you for the advice. However, when I add the node:
<xs:element name="Content">
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded" />
</xs:sequence>
</xs:element>
The <xs:sequence> node displays an error of: The active schema does not
support the element 'xs:sequence'. Then when I actually try to run the
validation I get the following exception:
"The 'http://www.w3.org/2001/XMLSchema:sequence' element is not supported in
this context. An error occurred at , (58, 22)."
Any idea what's going on?
--
Sincerely,
Drew Berkemeyer
Software Architect http://www.berkemeyer.com/
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:u9****************@TK2MSFTNGP12.phx.gbl...
Drew Berkemeyer wrote:
<MyEvent> <Header attribute1="true" attribute2="23"/> <Payload> </Payload> </MyEvent>
I would like to define an XSD that places strict validation on everything you see in the above example. However, I do not want *ANY* validation on the body of the <Payload> node.
You can use a definition alike <xs:element name="Payload"> <xs:sequence> <xs:any processContents="skip" maxOccurs="unbounded" /> </xs:sequence> </xs:element> see the xs:any definition in the W3X XML schema definition on http://www.w3.org/ for further options (to restrict contents to certain namespaces for instance).
--
Martin Honnen http://JavaScript.FAQTs.com/
Thank you for the advice. However, when I add the node:
<xs:element name="Content">
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded" />
</xs:sequence>
</xs:element>
The <xs:sequence> node displays an error of: The active schema does not
support the element 'xs:sequence'. Then when I actually try to run the
validation I get the following exception:
"The 'http://www.w3.org/2001/XMLSchema:sequence' element is not supported in
this context. An error occurred at , (58, 22)."
Any idea what's going on?
--
Sincerely,
Drew Berkemeyer
Software Architect http://www.berkemeyer.com/
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:u9****************@TK2MSFTNGP12.phx.gbl...
Drew Berkemeyer wrote:
<MyEvent> <Header attribute1="true" attribute2="23"/> <Payload> </Payload> </MyEvent>
I would like to define an XSD that places strict validation on everything you see in the above example. However, I do not want *ANY* validation on the body of the <Payload> node.
You can use a definition alike <xs:element name="Payload"> <xs:sequence> <xs:any processContents="skip" maxOccurs="unbounded" /> </xs:sequence> </xs:element> see the xs:any definition in the W3X XML schema definition on http://www.w3.org/ for further options (to restrict contents to certain namespaces for instance).
--
Martin Honnen http://JavaScript.FAQTs.com/
Drew Berkemeyer wrote: Hello,
How can I use XSD to ignore certain nodes of an XML document. Specifically, we have an event that I want to define using XSD. I then want to validate incoming XML events with that XSD. However, I want the payload section of the event to be freeform and thus, *NOT* validated.
Is there a way to define a node (and all of it's contents) in an XSD so that the validator requires that the node exists, but does not attempt to validate the contents of the node?
Example of the event: <MyEvent> <Header attribute1="true" attribute2="23"/> <Payload> </Payload> </MyEvent>
I would like to define an XSD that places strict validation on everything you see in the above example. However, I do not want *ANY* validation on the body of the <Payload> node.
Is this possible? We need this so that we can validate the format of the incoming event, but at the same time allow for free form, dynamic content in the payload.
Any assistance is appreciated.
Could the payload be CDATA or base64?
Well, we could encrypt the payload, but that would be non-optimal and would
require some changes to our existing system. I was considering the same
thing however if it is our only option.
Thank you for the suggestion.
--
Sincerely,
Drew Berkemeyer
Software Architect http://www.berkemeyer.com/
"anonymous" <fo******@nowhere.com> wrote in message
news:cs***********@news.cybercity.dk... Drew Berkemeyer wrote: Hello,
How can I use XSD to ignore certain nodes of an XML document. Specifically, we have an event that I want to define using XSD. I then want to validate incoming XML events with that XSD. However, I want the payload section of the event to be freeform and thus, *NOT* validated.
Is there a way to define a node (and all of it's contents) in an XSD so that the validator requires that the node exists, but does not attempt to validate the contents of the node?
Example of the event: <MyEvent> <Header attribute1="true" attribute2="23"/> <Payload> </Payload> </MyEvent>
I would like to define an XSD that places strict validation on everything you see in the above example. However, I do not want *ANY* validation on the body of the <Payload> node.
Is this possible? We need this so that we can validate the format of the incoming event, but at the same time allow for free form, dynamic content in the payload.
Any assistance is appreciated. Could the payload be CDATA or base64?
You need to write it like:
<xs:element name="Content">
<xs:complexType>
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
"Drew Berkemeyer" <sp**@menow.com> wrote in message
news:ue****************@TK2MSFTNGP11.phx.gbl... Thank you for the advice. However, when I add the node: <xs:element name="Content">
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded" />
</xs:sequence>
</xs:element>
The <xs:sequence> node displays an error of: The active schema does not support the element 'xs:sequence'. Then when I actually try to run the validation I get the following exception: "The 'http://www.w3.org/2001/XMLSchema:sequence' element is not supported
in this context. An error occurred at , (58, 22)."
Any idea what's going on?
--
Sincerely, Drew Berkemeyer Software Architect http://www.berkemeyer.com/
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:u9****************@TK2MSFTNGP12.phx.gbl...
Drew Berkemeyer wrote:
<MyEvent> <Header attribute1="true" attribute2="23"/> <Payload> </Payload> </MyEvent>
I would like to define an XSD that places strict validation on
everything you see in the above example. However, I do not want *ANY* validation
on the body of the <Payload> node.
You can use a definition alike <xs:element name="Payload"> <xs:sequence> <xs:any processContents="skip" maxOccurs="unbounded" /> </xs:sequence> </xs:element> see the xs:any definition in the W3X XML schema definition on http://www.w3.org/ for further options (to restrict contents to certain namespaces for instance).
--
Martin Honnen http://JavaScript.FAQTs.com/
Also, if you want to allow character data content (text) as well as child
elements in the Payload element, you would want to make its complex type
mixed by adding a mixed="true" attribute. And if you want to be valid even
if it has no children, you want to add a minOccurs="0" attribute to your
xs:any element, like this:
<xs:element name="Content">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
Hope that helps,
Priscilla
------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003 http://www.datypic.com
------------------------------------------------------------------
"Zafar Abbas [MSFT]" <za****@microsoft.com> wrote in message
news:uO****************@TK2MSFTNGP14.phx.gbl... You need to write it like:
<xs:element name="Content"> <xs:complexType> <xs:sequence> <xs:any processContents="skip" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element>
"Drew Berkemeyer" <sp**@menow.com> wrote in message news:ue****************@TK2MSFTNGP11.phx.gbl... Thank you for the advice. However, when I add the node: <xs:element name="Content">
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded" />
</xs:sequence>
</xs:element>
The <xs:sequence> node displays an error of: The active schema does not support the element 'xs:sequence'. Then when I actually try to run the validation I get the following exception: "The 'http://www.w3.org/2001/XMLSchema:sequence' element is not supported in this context. An error occurred at , (58, 22)."
Any idea what's going on?
--
Sincerely, Drew Berkemeyer Software Architect http://www.berkemeyer.com/
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:u9****************@TK2MSFTNGP12.phx.gbl... > > > Drew Berkemeyer wrote: > > >> <MyEvent> >> <Header attribute1="true" attribute2="23"/> >> <Payload> >> </Payload> >> </MyEvent> >> >> I would like to define an XSD that places strict validation on everything >> you see in the above example. However, I do not want *ANY* validation on >> the body of the <Payload> node. > > You can use a definition alike > <xs:element name="Payload"> > <xs:sequence> > <xs:any processContents="skip" maxOccurs="unbounded" /> > </xs:sequence> > </xs:element> > see the xs:any definition in the W3X XML schema definition on > http://www.w3.org/ for further options (to restrict contents to certain > namespaces for instance). > > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/
Perfect!
You guys are awesome! Thank you so much for your help. The solution works
like a champ! *EXACTLY* what I was hoping to do.
--
Sincerely,
Drew Berkemeyer
Software Architect http://www.berkemeyer.com/
"Priscilla Walmsley" <no****@datypic.com> wrote in message
news:e0****************@tk2msftngp13.phx.gbl... Also, if you want to allow character data content (text) as well as child elements in the Payload element, you would want to make its complex type mixed by adding a mixed="true" attribute. And if you want to be valid even if it has no children, you want to add a minOccurs="0" attribute to your xs:any element, like this:
<xs:element name="Content"> <xs:complexType mixed="true"> <xs:sequence> <xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element>
Hope that helps, Priscilla
------------------------------------------------------------------ Priscilla Walmsley Author, Definitive XML Schema / XML in Office 2003 http://www.datypic.com ------------------------------------------------------------------
"Zafar Abbas [MSFT]" <za****@microsoft.com> wrote in message news:uO****************@TK2MSFTNGP14.phx.gbl... You need to write it like:
<xs:element name="Content"> <xs:complexType> <xs:sequence> <xs:any processContents="skip" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element>
"Drew Berkemeyer" <sp**@menow.com> wrote in message news:ue****************@TK2MSFTNGP11.phx.gbl... Thank you for the advice. However, when I add the node: <xs:element name="Content">
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded" />
</xs:sequence>
</xs:element>
The <xs:sequence> node displays an error of: The active schema does not support the element 'xs:sequence'. Then when I actually try to run the validation I get the following exception: "The 'http://www.w3.org/2001/XMLSchema:sequence' element is not supported in this context. An error occurred at , (58, 22)."
Any idea what's going on?
--
Sincerely, Drew Berkemeyer Software Architect http://www.berkemeyer.com/
"Martin Honnen" <ma*******@yahoo.de> wrote in message news:u9****************@TK2MSFTNGP12.phx.gbl... > > > Drew Berkemeyer wrote: > > >> <MyEvent> >> <Header attribute1="true" attribute2="23"/> >> <Payload> >> </Payload> >> </MyEvent> >> >> I would like to define an XSD that places strict validation on everything >> you see in the above example. However, I do not want *ANY* validation on >> the body of the <Payload> node. > > You can use a definition alike > <xs:element name="Payload"> > <xs:sequence> > <xs:any processContents="skip" maxOccurs="unbounded" /> > </xs:sequence> > </xs:element> > see the xs:any definition in the W3X XML schema definition on > http://www.w3.org/ for further options (to restrict contents to > certain > namespaces for instance). > > > -- > > Martin Honnen > http://JavaScript.FAQTs.com/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike |
last post by:
Note: My XML experience to date has (unfortunately) been limited to reading
and thinking, rather than implementation.
Anyway, I am in the process of trying to figure out the most efficient way...
|
by: wumingshi |
last post by:
Hi,
When validating an XML instance, sometimes the schema is not enough to
expression the validation rules. Additional validation rules may be
expressed in an application-specific way. For...
|
by: Leonid Shprekher |
last post by:
Question to the Schema pro:
If nillable="False" is default for Schema element, why schema validation of
my XML doesn't fail if I don't provide any value for the tag?
Thanks,
Leonid.
|
by: Shone |
last post by:
I would like to perform a 2-pass XML reading from a stream. Once using
the Validating reader, just to confirm the validity against the
schema, and next time to do a reading to extract the data....
|
by: Dan Bass |
last post by:
There's an XML message I have, that has no namespace information.
Then there is a XSD schema that is must validate against, but this has a
targetNamespace and xmlns of...
| |
by: Stefano |
last post by:
Hi all,
what is the correct use of the "default" attribute in XML Schema?
For example:
<xs:element name="myProperty" type="xs:string" default="myDefaultValue"/>
What can I do with it? What...
|
by: Ali |
last post by:
I am having problem compiling schema contained in WSDL file when analyzing
schema types contained in it (for example
http://www.ebout.net/net/GoogleSearch.wsdl).
Following code demonstrates my...
|
by: billa1972 |
last post by:
Hi,
I am trying to hook into Yellow Freight's rating webservice. Below is the
wsdl. When i try and create a proxy file with wsdl.exe i get the following
errors, see below.
Also, when i...
|
by: wolf_y |
last post by:
My question is simply: under what conditions will empty tags of the
form <MOM></MOM> pass schema validation? Of course, the mirror
question is: under what conditions will empty tags fail...
|
by: Mark Parter |
last post by:
I'm trying convert an XML Schema
(http://www.elframework.org/projects/xcri/efc_r1.0.xsd/view) to a VB.Net
class using the XSD tool provided with the .NET 2 SDK. However, it's failing
to generate...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |