290
Points
Questions
56
Answers
51
-
Asked on July 17, 2020 in XML.
Full SGML (as opposed to the XML subset of SGML) has support for marked sections with
INCLUDE
orIGNORE
(orTEMP
) as marked section keyword, and the ability to use parameter entities in marked section declarations whereas XML has onlyCDATA
marked sections. You’d use it like this:<!DOCTYPE doc [ ... <!ENTITY % legacy "INCLUDE"> ]> ... <![ %legacy [ <elmt>Deprecated content</elmt> ]>
or even using
TEMP
as a dedicated construct to markup editorial content:<![ TEMP [ <elmt>...</elmt> ]>
While this can’t readily be a used with (just) XML (ie. unless you’re using SGML for XML authoring), I thought this might still inform an XML-based design in such a way that it carries over to and is aligned with SGML. Specifically, you’d use a dedicated XML element to wrap content deemed deprecated, rather than using eg. attributes for this purpose.
- 0 views
- 2 answers
- 0 votes
-
Asked on July 17, 2020 in XML.
Your XPath expression should work. But it selects the first
website
node whereas you want the second. You can use the following expression :/config/Website[@name='DefaultSite'][Property[@key='CertName']][Property[@key='Target' and @value='Webs']]
Or, as an alternative :
//Property[@key='CertName'][preceding-sibling::Property[@value="Webs"]]/..
Get the parent (
..
) of aProperty
element located anywhere (//
) in the XML tree. This element fulfill 2 conditions : contains a specific attribute (key=) and is preceded by a siblingProperty
element whith also a specific attribute (value=).Output is the second
Website
element of the tree :<Website name="DefaultSite"> <Property key="Target" value="Webs"/> <Property key="CertName" value="cert2"/> </Website>
- 345 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in XML.
Does this assume that the XSD Schema namespace is aliased (not sure if that’s the right term) as
xs
.Yes, namespace prefixes such as
xs
must be declared:xmlns:xs="http://www.w3.org/2001/XMLSchema"
Yes, you could use
foo
rather thanxs
, but go withxs
orxsd
as they’ve become the convention and so will surprise readers the least.
If you’re defining types directly in your XML, you’ll also want to declare,
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
and use it:
xsi:type="xs:string"
See also How to restrict the value of an XML element using xsi:type in XSD?
- 424 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
In .net 4 static Add() and Subtract() methods have been added.
IntPtr ptr = IntPtr.Add(oldPtr, 2);
http://msdn.microsoft.com/en-us/library/system.intptr.add.aspx
- 404 views
- 6 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
Choosing one representation is almost always about trade offs.
From here
A binary encoding is inherently less efficient for conversions to or from decimal-encoded data, such as strings (ASCII, Unicode, etc.) and BCD. A binary encoding is therefore best chosen only when the data are binary rather than decimal. IBM has published some unverified performance data.
Here you can find more about the relative performance.
Basically, it asserts your thoughts, that decimal significant is generally faster, but most operations show similar performance and binary even winning in division. Also keep in mind, since Intel mostly seems to rely on binary significants (i couldn’t find hints about other manufactures), they are more likely to get hardware support and than might beat decimals by a good margin.
- 488 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in .NET.
- 327 views
- 1 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
Warning: the approach described in this answer only applies to very specific scenarios and isn’t secure since SQL injection attacks do not only rely on being able to inject
X=Y
.If the attackers are trying to hack into the form via PHP’s
$_GET
variable or with the URL’s query string, you would be able to catch them if they’re not secure.RewriteCond %{QUERY_STRING} ([0-9]+)=([0-9]+) RewriteRule ^(.*) ^/track.php
Because
1=1
,2=2
,1=2
,2=1
,1+1=2
, etc… are the common questions to an SQL database of an attacker. Maybe also it’s used by many hacking applications.But you must be careful, that you must not rewrite a safe query from your site. The code above is giving you a tip, to rewrite or redirect (it depends on you) that hacking-specific dynamic query string into a page that will store the attacker’s IP address, or EVEN THEIR COOKIES, history, browser, or any other sensitive information, so you can deal with them later by banning their account or contacting authorities.
- 1047 views
- 28 answers
- 0 votes
-
Asked on July 16, 2020 in Mysql.
You can use
group_concat()
:select company_name, location, group_concat(tags separator ', ') from t group by company_name, location;
- 367 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in Python.
Try this:
my_str = "abra cadabra" my_set = set(my_str) my_set.discard(" ") my_dict = {} for key in my_set: my_dict[key] = my_str.count(key) print(my_dict)
- 348 views
- 2 answers
- 0 votes
-
Asked on July 16, 2020 in Algorithms.
Unfortunately
nx.draw_networkx_nodes
does not accept an iterable of shapes, so you’ll have to loop over the nodes and plot them individually. Also, we’ll have to index the generatedcmap
, otherwise, the single valued community values will get mapped to the same initial cmap color. For the possible shapes I’m just replicating the string of available shapes mentioned in the docs and indexing it based on the partition number:# load the karate club graph G = nx.karate_club_graph() # compute the best partition partition = community_louvain.best_partition(G) cmap = cm.get_cmap('viridis', max(partition.values()) + 1) shapes = 'so^>v<dph8' plt.figure(figsize=(12,8)) # draw the graph pos = nx.spring_layout(G) # color the nodes according to their partition cmap = cm.get_cmap('viridis', max(partition.values()) + 1) nx.draw_networkx_edges(G, pos, alpha=0.5) for node, color in partition.items(): nx.draw_networkx_nodes(G, pos, [node], node_size=100, node_color=[cmap.colors[color]], node_shape=shapes[color])
- 433 views
- 1 answers
- 0 votes