32191

How to restrict an element to be non-empty through xsd

Question:

I need to restrict the elements in xml file to be non empty using xsd files. Can I force the elements to contain only CDATA sections?

Answer1:

The only tool you have is the xs:string pattern restriction as in below. CDATA is just an alternative to escaping with entity references. You should use entity references in your pattern.

<simpleType name="NewType2"> <restriction base="string"> <minLength value="5"></minLength> <maxLength value="30"></maxLength> <pattern value="(&lt;html&gt;).*(&lt;/html&gt;)"></pattern> </restriction> </simpleType>

Recommend

  • Restric user access to table using Sql Server 2008
  • Unmarshalling works incorrectly: javax.xml.bind.UnmarshalException: unexpected element
  • AS3 String Memory Leak
  • JavaScript In KML Ignored By Google Earth Plugin
  • Selecting multiple elements with Selenium
  • Tag and Element shortcuts - Sublime Text 2
  • How create references between elements in XML
  • Handle Authentication and Authorization in jax-rs webservice with cxf
  • Root element minOccurs or maxOccurs
  • Compiling Element Causes Input Caret Position to Move to End
  • jquery add an event handler to objects in an array
  • iOS custom UTI in UIDocumentPickerViewController initWithDocumentTypes
  • how to display   in Mozilla using XSL.
  • R h2o.glm - issue with max_active_predictors
  • Is there any purpose for h2-h6 headings in HTML5?
  • IE6 changes DOCTYPE to a bad one
  • Click on button in another program - FindWindow, C#
  • VSCode change debug shell to bash on windows
  • Doctrine/Symfony entity generator and generating entity from one table
  • Using $compile in a directive triggers AngularJS infinite digest error
  • Does Apple allow the usage of sysctl.h within iOS applications?
  • Default parameter as generic type
  • Why use database factory in asp.net mvc?
  • Play WS (2.2.1): post/put large request
  • Moving mysql files across servers
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • WinForms: two way TextBox problem
  • Deserializing XML into class C#
  • When should I choose bucket sort over other sorting algorithms?
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • R: gsub and capture
  • AT Commands to Send SMS not working in Windows 8.1
  • Unanticipated behavior
  • Is there a mandatory requirement to switch app.yaml?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++
  • How to Embed XSL into XML