regular expression pattern matching in XML schema
Having trouble installing Oxygen? Got a bug to report? Post it all here.
regular expression pattern matching in XML schema
Post by Susheel »
Hi,
I have an element "<foo>" with an attribute "name". The name invariably starts with a prefix ADD_. So all names look like ADD_integers or ADD_floats etc.
I am trying to put a pattern check for this attribute in the XML schema to ensure that the name starts with ADD_.
Can I do this in the schema? If yes,What would be the pattern value for this?
Thanks,
Susheel
I have an element "<foo>" with an attribute "name". The name invariably starts with a prefix ADD_. So all names look like ADD_integers or ADD_floats etc.
I am trying to put a pattern check for this attribute in the XML schema to ensure that the name starts with ADD_.
Can I do this in the schema? If yes,What would be the pattern value for this?
Thanks,
Susheel
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi,
The following schema should be close to what you want:
See http://www.w3.org/TR/xmlschema-2/#rf-pattern for more information about pattern constraints in XML Schema.
Best Regards,
George
The following schema should be close to what you want:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="foo">
<xs:complexType>
<xs:attribute name="name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="ADD_.+"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
Best Regards,
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service