Is it possible to define parameter for a type ? I want to have type that represents fixed length string but I dont want do define multiple such types for different lengths, that is TFixedString(N) so I could use TFixedString(2) and TFixedString(16).
No you can not do this. It is not supported in XSD.
Related
I want the following behaviour:
class RealEstate:
rooms
Suddenly the following results in an Unresolved reference Error: NameError: name 'rooms' is not defined.
I am aware that I can assign None to the variable:
class RealEstate:
rooms = None
Or define the type:
class RealEstate:
rooms: float
Both will work. But it is not what I want. I want it as simple as possible and with less typing. Is there any way to make the first example work? Maybe some Metaclasses magic, some brilliant decorators, extending some special classes or libraries that can help?
No, you can't "define" a variable by writing its name alone. It will be evaluated as an expression and if it doesn't exist already it will raise a NameError.
You can either
"define" a variable by using an assignment name = value (it binds a name to a value at runtime, and you need to specify the value), or
"define" a variable by using a type annotation name: type (it associates a name with a type, for which you need to specify the type, but does not automatically create the name or any value at runtime).
Given a Julia object of composite type, how can one determine its fields?
I know one solution if you're working in the REPL: First you figure out the type of the object via a call to typeof, then enter help mode (?), and then look up the type. Is there a more programmatic way to achieve the same thing?
For v0.7+
Use fieldnames(x), where x is a DataType. For example, use fieldnames(Date), instead of fieldnames(today()), or else use fieldnames(typeof(today())).
This returns Vector{Symbol} listing the field names in order.
If a field name is myfield, then to retrieve the values in that field use either getfield(x, :myfield), or the shortcut syntax x.myfield.
Another useful and related function to play around with is dump(x).
Before v0.7
Use fieldnames(x), where x is either an instance of the composite type you are interested in, or else a DataType. That is, fieldnames(today()) and fieldnames(Date) are equally valid and have the same output.
suppose the object is obj,
you can get all the information of its fields with following code snippet:
T = typeof(obj)
for (name, typ) in zip(fieldnames(T), T.types)
println("type of the fieldname $name is $typ")
end
Here, fieldnames(T) returns the vector of field names and T.types returns the corresponding vector of type of the fields.
How can i use AND operation on jape grammar?. I just want to check whether a sentence contain 'organisation','jobtitle','person' all together in any order. How it possible? There is '|'(OR) operation allowed but i didnt see any documentation about AND operation.
There isn't an "and" operator like that as such but you could do it with a set of contains checks:
Rule: OrgTitlePer
({Sentence contains {Organization},
Sentence contains {JobTitle},
Sentence contains {Person}}):sent
-->
:sent.Interesting = {}
When you have several constraints within the same set of braces that involve the same annotation type on the left (Sentence in this case) then all the constraints must be satisfied simultaneously by the same annotation.
I have scenario for which i need to write the pattetn in xsd for below scenarios. pls help
1) String can have value from 0 to 4532 (max value)
2) it can also contain value in terms of ranges like 100-4352 or 100-200 or 0 - 4532 (any possible range value . max value of the range is 4532)
it can consist '-' hypen as well so i am trying to define type as String.
pls let me know if there is any better way to specify the same in xsd other than pattern.
thanks in advance.
I guess the pattern will be only chance how to do it. But I think it will be painful thing.
Just an idea - is it necessary to have this type as simple type? IMO it could be better to have it as (e.g.) complex type with two attributes (from, to). These two attributes could be of type constraining their content to the specified range 0-4532.
I have a class in UML that looks like this (it's in German, but I think it doesn't matter):
The first method takes an array of 4 "Rohstoffkarte". That's an abstract class and I have 5 concrete sub-classes for it. Now I want to check (with OCL) that all 4 instances in the array are from the same sub-class.
Any idea how to do this? I'm working with MagicDraw.
Thanks.
you can use
oclIsKindOf, oclIsTypeOf to check type conformance, and use oclType to get the type of an object.
See OMG Object Constraint Language Specification Version 2.3.1, p.22
http://www.omg.org/spec/OCL/2.3.1