Html Entity Name vs entity Number? - asp.net

I saw this table :
when I program Asp.net and want to display these special html entities , I use Entity Name.
(but both seems to work)
question :
in what scenarios should I use entity number ( and not entity name ) ?
p.s. Ive seen situation in which asp.net doesnt like Entity Number

There is not clear guidance as to when one should use a numeric character reference (say £) over a character entity reference (say £) or vice versa.
So long as a character entity reference is a defined one (you can define your own), you can use it.
The converse is that if it isn't defined, you should use a numeric character reference.

There is no need to use either of them for most characters. Just enter the characters, in UTF-8, or in ISO-8859-1, whichever you are using. If you don’t know how to type a no-break space, for example, and don’t want to learn it, the entity reference and the character reference   are equivalent, so use whichever you find less confusing. (The latter is not an entity reference, so “Entity Number” is a misnomer.)
Only for “<” and for “&”, when used as data characters, will you need “escape” notations, and for them, I cannot figure out any reason why you would use character references, instead of the reasonably mnemonic entity references < and &.

Related

Using shacl to validate a property that has at most one value in its properties

I'm trying to create a shacl based on the ontology that my organization is developing (in dutch): https://wegenenverkeer.data.vlaanderen.be/
The objects described have attributes (properties), that have a specified datatype. The datatype can a primitive (like string or decimal) or complex, which means the property will have properties itself (nested properties). For example: an asset object A will have an attribute assetId which is a complex datatype DtcIdentificator, which consists of two properties itself. I have succesfully created a shacl that validates objects by creating multiple shapes and nesting them.
I now run into the problem of what we call union datatypes. These are a special kind of complex datatypes. They are still nested datatypes: the attribute with the union datatypes will have multiple properties but only exactly zero or one of those properties may have a value. If the attribute has 2 properties with values, it is invalid. How can I create such a constraint in shacl?
Example (in dutch): https://wegenenverkeer.data.vlaanderen.be/doc/implementatiemodel/union-datatypes/#Afmeting%20verkeersbord
A traffic sign (Verkeersbord, see https://wegenenverkeer.data.vlaanderen.be/doc/implementatiemodel/signalisatie/#Verkeersbord) can have a property afmeting (size) of the datatype DtuAfmetingVerkeersbord.
If an asset A of this type would exist, I could define its size as (in dotnotation):
A.afmeting.rond.waarde = 700
-or-
A.afmeting.driehoekig.waarde = 400
Both are valid ways of using the afmeting property, however, if they are both used for the same object, this becomes invalid, as only one property of A.afmeting may have a value.
I have tried using the union constraint in shacl, but soon found out that that has nothing to do with what we call "union datatypes"
I think the reason you are struggling is because this kind of problem is usually modelled differently. Basically you have different types of Traffic signs and these signs can have measurements. With the model as you described, A.afmeting.rond.waarde captures 2 ideas using 1 property: (a) the type and (b) the size. From your question, this seems to be the intend. However, this is usually not how this kind of problem is addressed.
A more intuitive design is for Traffic sign to have 2 different properties: (a) type and (b) a measurement. The Traffic sign types are achthoekig, driehoekig, etc. Then you can use SHACL to check that a traffic sign has either both or no properties for a traffic sign.

Define custom property of type date and use it in query

The professional version of Artifactory allows to define custom properties for artifacts. Usually, these are key/value pairs where the value is a String.
Is it also possible to use dates (or numbers) as value?
I would like to define a property like "doNotUseAfter" with a date. Then I would like to use the Artifactory query language to find out which artifacts have a doNotUseAfter date that is already in the past.
All property values are strings, or collections of strings. There is no type information built-in to properties. However, if you format your dates as strings using a sortable encoding (such as ISO 8601), you can use an AQL query to string-compare to the current date in the same format.
For example, if your artifact has a property doNotUseAfter: 2018-10-22, you can use the following AQL query to find it:
items.find({"#doNotUseAfter": {"$lt": "2019-02-01"}})
Note that AQL does have specific support for date and numeric data, but as far as I can tell, that only applies to fields like modified or size that always have those types; I'm fairly certain it doesn't parse arbitrary properties as one type or another based on formatting. This could cause problems when sorting or comparing numeric properties, since the string "5" is considered larger than "43" for example, but for dates and timestamps in a sortable format, there is no such issue.

How does one convert string to number in JDOQL?

I have a JDOQL/DataNucleus storage layer which stores values that can have multiple primitive types in a varchar field. Some of them are numeric, and I need to compare (</>/...) them with numeric constants. How does one achieve that? I was trying to use e.g. (java.lang.)Long.parse on the field or value (e.g. java.lang.Long.parseLong(field) > java.lang.Long.parseLong(string_param)), supplying a parameter of type long against string field, etc. but it doesn't work. In fact, I very rarely get any errors, for various combinations it would return all values or no values for no easily discernible reasons.
Is there documentation for this?
Clarification: the field is of string type (actually a string collection from which I do a get). For some subset of values they may store ints, e.g. "3" string, and I need to do e.g. value >= 2 filters.
I tried using casts, but not much, they do produce errors, let me investigate some more
JDO has a well documented set of methods that are valid for use with JDOQL, upon which DataNucleus JDO adds some additional ones and allows users to add on support for others as per
http://www.datanucleus.org/products/accessplatform_3_3/jdo/jdoql.html#methods
then you also can use JDOQL casts (on the same page as that link).

Filtering a multivalued attribute in StringTemplate

I have a template which uses the same multivalued attribute in various places. I often find myself in a situation where I would like to filter the attribute before a template is applied to the individual values.
I can do this:
<#col:{c|<if(cond)><# c.Attribute2 #><endif>};separator=\",\"#>
but that is not what I want, because then there are separators in the output separating "skipped" entries, like:
2,4,,,6,,4,5,,
I can modify it to
<#col:{c|<if(c.Attribute1)><# c.Attribute2 #>,<endif>};separator=\"\"#>
Which is almost OK, but I get an additional separator after the last number, which sometimes does not matter (usually when the separator is whitespace), but sometimes does:
2,4,6,4,5,
I sometimes end up doing:
<#first(col):{c|<if(cond)><# c.Attribute2 #><endif>};separator=\"\"#>
<#rest(col):{c|<if(cond)>,<# c.Attribute2 #><endif>};separator=\"\"#>
But this approach fails if the first member does not satisfy the condition, then there is an extra separator in the beginning:
,2,4,6,4,5
Can someone give me a better solution?
First, let me point out that I think you are trying to do logic inside your template. Any time you hear things like "filter my list according to some condition based upon the data" it might be time to compute that filtered list in the model and then push it in. That said something like this might work where we filter the list first:
<col:{c | <if(c.cond)>c<endif>}:{c2 | <c2.c.attribute>}>
c2.c accesses the c parameter from the first application
The answer by "The ANTLR Guy" didn't help in my case and I found another workaround. See at Filter out empty strings in ST4

How determine primitive type in WPF DataGrid (when using AutoGenerateColumn)?

How can I determine the primitive Type of the bound column to a DataGrid control, when the control is created using AutoGeneratingColumn?
I have looked in all these classes: DataGridColumn, DataGridBoundColumn, DataGridTextColumn, and DataGridBoundColumn.Binding.
I am unable to determine which Type (primitive type) the columns are bound to. (They are Bound to a SQL table.) I want to apply different styles and converters based on the type. I could Hard Code these styles and converters based on the column name (which I can get from DataGridTextColumn.Header), but I want to AVOID THAT AT ALL COSTS!
Looks like I found the answer.
The type is passed into the "AutoGeneratingColumn" handler as e.PropertyType.
The problem is, it isn't the real type. It must be boxed, because even though the database column is "nullable" the type passed isn't.
So, I am going to have to "Hard Code" my solution, based on Column Name. :(

Resources