Coder Social home page Coder Social logo

Comments (9)

CBenghi avatar CBenghi commented on June 26, 2024

Indeed it seems to be possible, see https://www.w3.org/TR/2011/CR-xmlschema11-2-20110721/datatypes.html#rf-pattern
I will add a test case to the repository to have this documented.

from ids.

CBenghi avatar CBenghi commented on June 26, 2024

@LoamsDw,

<xs:pattern value="^.{3}(CA)(.{4}(MT))(.{4}(DTM)).*" />

please note that the pattern assumes a full match with the string, so you need to remove the initial ^ in your values.

from ids.

andyward avatar andyward commented on June 26, 2024

Presumably as a workaround you can use the built in OR operator in a regex. e.g. using | to separate the patterns

<xs:pattern value=".{3}(CA)(.{4}(MT))(.{4}(DTM)).*|.{3}(CN)(.{4}(AC))(.{4}(CNT)).*| etc " />

But obviously it make it pretty unwieldy.

from ids.

CBenghi avatar CBenghi commented on June 26, 2024

@andyward,

Apologies, I was not explicit enough earlier.

The proposed case is valid, with the following minor correction:

<propertySet>
	<simpleValue>Pset_exemple</simpleValue>
</propertySet>
<name>
	<simpleValue>WBS Code</simpleValue>
</name>
<value>
	<xs:restriction base="xs:string">
		<xs:pattern value=".{3}(CA)(.{4}(MT))(.{4}(DTM)).*" />
		<xs:pattern value=".{3}(CN)(.{4}(AC))(.{4}(CNT)).*" />
		<xs:pattern value=".{3}(CS)(.{4}(AS))(.{4}(ASS)).*" />
		<xs:pattern value=".{3}(CS)(.{4}(SR))(.{4}(ARG|BAE|BIN|CCU|FLE|FSC|GEO|GRA|MUS|PAV|RIL|SCO|TVE)).*" />
		<xs:pattern value=".{3}(CS)(.{4}(ST))(.{4}(BAE|BIN|CCU|FLE|FSC|GEO|MUS|PAV|SCO|TRN|TVE)).*" />
		<xs:pattern value=".{3}(CV)(.{4}(FP))(.{4}(PMD)).*" />
		<xs:pattern value=".{3}(CV)(.{4}(FS))(.{4}(PZF)).*" />
		<xs:pattern value=".{3}(CV)(.{4}(IA))(.{4}(BIN|VEL)).*" />
		<xs:pattern value=".{3}(CV)(.{4}(IC))(.{4}(BIN|CCP|CCU|GDI|MUS|PAV|PRE|SCA|TCC)).*" />
		<xs:pattern value=".{3}(CV)(.{4}(PI))(.{4}(BAG|ISA|PUL|SEL)).*" />
		<xs:pattern value=".{3}(CV)(.{4}(SP))(.{4}(BAG|ISA|MAN|MFP|RIE|SFL)).*" />
	</xs:restriction>
</value>

The XML documentation at https://www.w3.org/TR/2011/CR-xmlschema11-2-20110721/datatypes.html#rf-pattern states that:

An XML containing more than one element gives rise to a single ·regular expression· in the set; this ·regular expression· is an "or" of the ·regular expressions· that are the content of the elements.

Therefore the restriction is considered a pass, if any of the provided patterns matches the value.

I don't see the need for the workaround you are proposing. Am I missing something?

from ids.

andyward avatar andyward commented on June 26, 2024

I don't see the need for the workaround you are proposing. Am I missing something?

I was just assuming this might need additional support/testing in the relevant implementations. e.g. I just checked XIDS and I don't think it's correctly de-serialising multiple patterns in this way , and may not be the only implementation to have overlooked this.

from ids.

CBenghi avatar CBenghi commented on June 26, 2024

I don't see the need for the workaround you are proposing. Am I missing something?

I was just assuming this might need additional support/testing in the relevant implementations. e.g. I just checked XIDS and I don't think it's correctly de-serialising multiple patterns in this way , and may not be the only implementation to have overlooked this.

Are you suggesting that we add an implementer agreement to constrain this?

from ids.

andyward avatar andyward commented on June 26, 2024

Are you suggesting that we add an implementer agreement to constrain this?

I'm not sure how best - but it feels like an edge case that may cause discrepancies if we don't formalise it. Can we cover off in the 'Complex restrictions' markdown somehow? And ideally have some test cases.

Is it just pattern that can be repeated like this in a restriction? The XSD docs don't appear indicate that any of the other Constraining Facets can be duplicated, so I guess pattern is an exception. E.g. An enumeration's 'or' operates at the next level down - so there's only ever one enumeration in a restriction.

from ids.

LoamsDw avatar LoamsDw commented on June 26, 2024

Presumably as a workaround you can use the built in OR operator in a regex. e.g. using | to separate the patterns

<xs:pattern value=".{3}(CA)(.{4}(MT))(.{4}(DTM)).*|.{3}(CN)(.{4}(AC))(.{4}(CNT)).*| etc " />

But obviously it make it pretty unwieldy.

I don't know if it can be useful but I did some tests and I get the result I want just by concatenating the patterns with the "|" separator even though it doesn't seem to be the most elegant solution it worked

from ids.

berlotti avatar berlotti commented on June 26, 2024

A combination of (multiple) patterns and other restrictions like enumerations, min/max restrictions, etc. is also possible.

from ids.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.