Which parser JSX uses? - parsing

As mention in name JSX and it's restriction like must have closing tag etc.
I think JSX uses XML parser.
if uses XML then why choose XML not HTML ?

From the docs:
"JSX Specification: XML-LIKE SYNTAX EXTENSION TO ECMASCRIPT"
To answer your question: "why choose XML not HTML", because this allows it to be a superset of HTML with the inclusion of user defined tags. For example it allows you to define a "MyApp" tag (component) and use it: <MyApp name="some name" />. As it's an "XML-LIKE SYNTAX EXTENSION TO ECMASCRIPT" this allows you to use it along side javascript:
function calculatedComplexName() {
return "some complex name";
}
<MyApp name={calculatedComplexName()}/>

Related

IBM Integration Bus and xsd:anyType

I'm working with IIB v9 mxsd message definitions. I'd like to define one of the XML elements to be of type xsd:anyType. However, in the list of types I can choose from, only anySimpleType and anyUri are possible (besides all other types like string, integer, etc.).
How can I get around this limitation?
The XMLNSC parser supports the entire XML Schema specification, including xs:any and xs:anyType. In IIBv9 you should create a Library and import your xsds into it. Link your Application to the Library and the XMLNSC parser will find and use the model. You do not need to specify the name of the Library in the node properties; the XSD model will be automatically available to the entire application.
You do not need to use a message set at all in IIBv9 and later versions.
The mxsd file format is used only by the MRM (not DFDL) parser.
You shouldn't use an MXSD to model your XML data, use a normal XSD.
MXSD is for modelling data for the DFDL parser, but you should use the XMLNSC parser for XML messages and define them in XSDs, in which you can use anyType.
As far as I know DFDL doesn't support anyType.

Is it possible to parse/read javascript - like notation - Objective-C

I have a file that tells me what to do on runtime.
Notation is as below;
<Service name="Service2">
<Request>
<User value="admin">
<Pass value="1234">
</Request>
Is it possible to parse it with standard rules, without writing custom parser?
Thanks
As the above text are in file, you will read it as NSString. After reading the file you can either use some algorithm to fetch the value like, breaking the string into arrays separated by < and >
or, you can create your own parser.
As you dont want to form your custom parser, then you can use the first way to find the values, but that will be fixed for the above file contents.

Do we need to add html extension to partials?

Let we have a partial _form.html.slim
It seems that there is no difference for rails add you the html extension or not so we can remove the html extension. _form.slim will be the same partial and works well.
Is there any difference?
Common format handling
The scheme for a template is : <action_name>.<format>.<preprocessors>.
Adding format extension is a mean to constrain template on that filetype, but it's totally optional, just like preprocessor.
If for example you were to implement a foos/index.erb template, it could be used to render either http://host/foos, http://host/foos.json, http://host/foos.html or whatever mime type you use. Using foos/index.html.erb, you specify this template should only be used for html.
Formats the template may be use for with no format constraint depends on :
the use or not of #respond_to in your controller, forcing allowed formats
the default recognized formats
There are quite a bunch of default recognized mime types, as of now : html, text, js, css, ics, csv, png, jpg, gif, bmp, tiff, mpeg, xml, rss, atom, yaml, json, pdf, zip.
If you were to specify both a file name with format forced and a one without, the forced format template would take precedence for that given format (so, if you have foos/index.html and foos/index, the first one will be used to render html pages, while the second one will be used for any other format).
Note that since both format and preprocessor are optional, you could have just a foos/index file if you want. That would serve a static file (not preprocessed) for all default formats.
With partials
The exact same rules apply to partials. If you specify a format, the partial will only be used for that format. You may specify multiple partials having each their format, and you can omit format to use the same partial for all formats.
yes you may do it but that partial will be rendered as js and css as well. So if possible try to avoid it
I'm not sure in this case, but html is the content type and slim would be the template engine. The filename.content_type.template_engine format separates it out to be processed. It may have worked for you to remove the html extension, but I believe it to be best practice to keep the extensions in place.

Search cssutils.py parse tree by ID and CLASS selectors

I'm using cssutils in Python to parse CSS style files and would like to search the parse tree by ID and Class. That is, given some CSS style file and some Class name (e.g. div navbar), how do I ascertain the style rules encapsulated by this selector? A solution or any ideas about where to look in the existing documentation (http://packages.python.org/cssutils/index.htm) would be highly appreciated
You can try this out:
import cssutils
css_parser = cssutils.CSSParser()
stylesheet = css_parser.parseUrl(CSS_URL)
for each_rule in stylesheet.CSSRules:
if ID_NAME in each_rule.selectorText:
print each_rule.style
Similarly you can try for CLASS_NAME as well.
Would this work for you?

How to write javadoc links?

How do I write links into javadocs?
Currently, I have something like:
{#link java.lang.Math#sqrt(double) Math.sqrt}
to produce the text Math.sqrt that should link to the java.lang.Math.sqrt(double) API, however, all it does is produce the text, no link.
My answer is very much provided by Eddie, but his exact code doesn't work for me (or at least when using the version of javadoc that comes with Java 1.6)
If I do:
javadoc -linkoffline http://java.sun.com/javase/6/docs/api/
http://java.sun.com/javase/6/docs/api/package-list
-public FileName.java
then javadoc complains:
javadoc: warning - Error fetching URL:
http://java.sun.com/javase/6/docs/api/package-list/package-list
If, on the other hand, I do:
javadoc -linkoffline http://java.sun.com/javase/6/docs/api/
http://java.sun.com/javase/6/docs/api/
-public FileName.java
Then it works, and my links are populated as I want them to be.
Additionally, my link isn't malformed. The text {#link java.lang.Math#sqrt(double) Math.sqrt} produces the link text Math.sqrt instead of the default Math.sqrt(double).
To get a link to something external to your code, you need use the -linkoffline option
where the -linkoffline option has the format something like this (artificially wrapped):
-linkoffline http://java.sun.com/javase/6/docs/api/
http://java.sun.com/javase/6/docs/api/
This tells the JavaDoc tool where to find the link to the JavaDoc and for what packages to use that link. From the 2nd URL, it will append "package-list" to load the actual URL:
http://java.sun.com/javase/6/docs/api/package-list
which you can verify by loading it in a browser does contain the list of packages documented at that JavaDoc URL. This tells the JavaDoc tool that any #link references to anything in one of those packages should link to the provided URL.
I believe for what you're trying to do, you can do this:
#see java.lang.Math#sqrt(double)
It doesn't give you the alternate text, but it gives you the link.
You can also write a more generic link like using standard html:
Google
This document might be of assistance, remember that for #link you need to use the URL for the doc you are linking to.

Resources