Note that there are some explanatory texts on larger screens.

plurals
  1. POEmded XHTML snippet in XML document, and validate against a schema
    text
    copied!<p>Essentially I want to embed some XHTML in an XML document that must validate against a custom schema.</p> <p>Full background:</p> <p>I have a webservice that consumes an XML document. This XML document is validated against a custom schema. The data in the XML is parsed and stored in a database, and displayed in a useful format on a website.</p> <p>The customer who fires the XML at my webservice has its own internal "IT / programmer guy". He wants to be able to display some custom XHMTL in some placeholders on some of the websites pages.</p> <p>We have agreed that he can extend the XML that he fires at my webservice to include 3 new elements that will contain the HTML, and I will adjust my schema accordingly. I'll also do the processing to get his XHTML out of the XML doc an on to the web pages.</p> <p>I don't want to use cdata as that could be quite insecure (I think!), so I was trying to use an <code>&lt;xs:any&gt;</code> in the schema:</p> <pre><code>&lt;xs:element name="SomeXhtmlStuff" minOccurs="0"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:any minOccurs="0"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; </code></pre> <p>I was thinking this would mean that any valid XML would be OK in the element, e.g. all XHTML tags would be fine, however I tried this:</p> <pre><code>&lt;SomeXhtmlStuff&gt; &lt;p&gt;This is a test HTML output for Job Details&lt;/p&gt; &lt;/SomeXhtmlStuff&gt; </code></pre> <p>and the XML won't validate against it. Edit: Visual Studio 2008 in it automatic validator gives the error "the 'p' element is not declared"</p> <p>I haven't got much experience with XML/schema and I inherited this project, any suggestions would be more than welcome!</p> <p>Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload