65948

How to allow xml:lang attribute in XMLSchema?

Question:

I want to allow the use of xml:lang attributes in some of my element of my XMLSchema. But i can't find anything which describes how to to it. Yeah, my question is simple as that.

Answer1:

You can either create your own attribute with xmlschema type <a href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#language" rel="nofollow">language</a>, or reference xml:lang attribute as in the example <a href="http://www.java2s.com/Code/XML/XML-Schema/importanotherXMLschema.htm" rel="nofollow">Import another XML schema</a>. I hope this will help.

Answer2:

You have to do a bit of hunting to piece this together from the standards. Here's the magic sauce you need in order to allow xml:lang attributes on your XML elements.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- Import xml: namespace --> <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd" /> <!-- ... ---> <xs:complexType name="myLanguagedElement"> <!-- ... --> <!-- use ref="" instead of name="", here in your attribute --> <xs:attribute ref="xml:lang" use="optional" /><!-- or "required" if you like --> </xs:complexType> </xs:schema>

Recommend

  • Fastdebug/debug builds for JDK 7
  • How to execute PowerShell script as Azure Automation Runbook from InlineScript inside PSWorkflow run
  • How do I get C++ programs to link with gcc's stack protector feature on AIX?
  • iCloud versus iCloud Drive versus CloudKit
  • Select an attribute with Xpath in a XML with namespace using Powershell
  • Spring custom user details service null pointer exception
  • SessionInformation expiration doesn't lead to user log out from system
  • XSD with multi occurrences unordered
  • in batch how do i use taskkill properly
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • Clear activity stack before launching another activity
  • NUnit 3.0 TestCase const custom object arguments
  • GAE: Way to get reference to an HttpSession from its ID?
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • What is the purpose of TaskExecutor in spring?
  • Automatically associate new Sonar project with custom quality profile and quality gate
  • What does 'Language neutral' mean with regard to MAKELANGID?
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • Android activity accessing service's static reference before the service is ready
  • Play WS (2.2.1): post/put large request
  • Allowing both email and username for authentication
  • Refering to the class itself from within a class mehod in Objective C
  • Switching to Release Build causes runtime error in Web Reference
  • formatting the colorbar ticklabels with SymLogNorm normalization in matplotlib
  • Get one-time binding to work for ng-if
  • HTML download movie download link
  • Deserializing XML into class C#
  • How do you troubleshoot character encoding problems?
  • Why winpcap requires both .lib and .dll to run?
  • Return words with double consecutive letters
  • Is there a mandatory requirement to switch app.yaml?
  • Python: how to group similar lists together in a list of lists?
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do I configure my settings file to work with unit tests?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Django query for large number of relationships
  • Busy indicator not showing up in wpf window [duplicate]
  • Binding checkboxes to object values in AngularJs
  • How to Embed XSL into XML