How to select the right <category> in RSS? is there a list? - rss

i am noting that in a RSS feed you can add the tag
Source: https://www.w3schools.com/xml/rss_tag_category_item.asp
But I don't undestand one thing: is there a list with all the categories? Or can I write anything? I need a category about videogames

Or can I write anything?
You can write anything.
Unless you're submitting your feed to a directory, with a documented set of categories, it's essentially free text.
However, in RSS:
It has one optional attribute, domain, a string that identifies a categorization taxonomy.
The value of the element is a forward-slash-separated string that identifies a hierarchic location in the indicated taxonomy.
and in Atom:
The "scheme" attribute is an IRI that identifies a categorization
scheme.
you can indicate that your term is from a specific scheme.
In practice, some schema extensions like iTunes introduce a separate element:
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
...
<itunes:category text="Sports">
<itunes:category text="Wilderness"/>
</itunes:category>
rather than suggesting use of the scheme attribute. The iTunes guide currently includes:
<itunes:category text="Leisure">
<itunes:category text="Video Games" />
</itunes:category>

Related

Match XML elements/nodes that contain 'X' with XPath

I'm using the WP-Property and WP-Property: Importer plugins to manage properties on a WordPress powered website. The importer uses xpath rules to help map fields in an imported XML file to their corresponding field on the site.
e.g. 'Display Address' maps to 'address/full'
I have a set of elements that look like this:
<property>
<feature1>Feature</feature>
<feature2>Feature</feature>
<feature3>Feature</feature>
<feature4>Feature</feature>
<feature5>Feature</feature>
<address>
<full>abc</full>
<street>def</street>
<postcode>ghi</postcode>
</address>
</property>
I want to group these together into one entry rather than setting up separate fields for each one, so I'm looking for a means to match feature* but everything I've tried so far seems to have missed the mark. Goes without saying that I've never dabbled with xpath before today!

jsonapi.org correct way to use pagination using the page query string

In the documentation for jsonapi for pagination is says the following:
For example, a page-based strategy might use query parameters such as
page[number] and page[size]
How would I represent this in the query string? http://localhost:4200/people?page[number]=1&page[size]=25, I don't think using a map link structure is a valid query string. Only the page parameter is reserved according to the documentation.
I don't think using a map link structure is a valid query string.
You're right technically, and that's why the spec has the note that says:
Note: The example query parameters above use unencoded [ and ] characters simply for readability. In practice, these characters must be percent-encoded, per the requirements in RFC 3986.
So, page[size] is really page%5Bsize%5D which is a valid query parameter name.
Only the page parameter is reserved according to the documentation.
When the spec text says that only page is reserved, it actually means that any page[......] style query parameter is reserved. (I can tell you that for sure as one of the spec's editors.) But it should say so more explicitly, so I'll open an issue for it.

What is wrong with the xml code

I got this question in an exam to specify what is wrong with this piece of XML code and I have no idea what the answer might be:
<contact id=”10” name=”randomName” email=”first.last#gmail.com” phone=”09090909”/>
I am guessing that the email would be prone to spam or something.
Original answer: you cannot name an attribute "id" in XML for your own purpose. It is a reserved name of the XML schema space which actually serves to identify a specific element to then do a look up by XML id.
EDIT
The issue with the XML might be a modeling one. The fact you use attributes for name, email, and phone means that a contact can only ever have one value of each. Maybe your professor is after a new model e.g.:
<contact id="10" name="foo">
<email>sdfsdfsdf</email>
<email>sdfsdfsdf</email>
</contact>
XML attributes are not intended to carry the object data.
Your XML should be structured like this:
<contact>
<id>10</id>
<name>randomName</name>
<email>first.last#gmail.com</email>
<phone>09090909</phone>
</contact>
Further reading: http://www.w3schools.com/xml/xml_attributes.asp

Can I create a reblog link from a Tumblr RSS feed?

Can I Create a reblog link programatically?
Is it against the terms of service? I can't tell...
Anatomy of a tumblr reblog link: (unique numbers made up)
http://www.tumblr.com/reblog/85728493821/7vu4jf89
In my RSS feed I have:
myblog.tumblr.com/post/85728493821
So its safe to say the 85... number is a unique post id
But what is the other code? (7vu4jf89)
The 2nd value differs for each reblog link, so its not just my unique identifier.
Arbitrary values do not work either.
I was thinking maybe its something Tumblr implemented specifically to prevent people from doing the sort of thing I'm attempting? Maybe its some sort of hash value combining my account identifier and the post?
Any insight is appreciated.
Tumblr Reblogs
Ignoring the RSS part for the moment, I believe there are two official methods to achieve a working reblog link.
Use the template variable {ReblogButton} (http://www.tumblr.com/docs/en/custom_themes#like_and_reblog_buttons)
Use the Tumblr API (http://www.tumblr.com/docs/en/api/v2#reblogging)
In reply to your question about other code. I believe this is a unique, randomly generated key, the make up of which I am not 100% sure on. The key seems be unique per post and per site.
For example, if the original reblog key is 12345678 and the post is reblogged, a new key is generated for the site that reblogged the post.
Back to the RSS part, sadly as you have probably gathered, getting the reblog key inside the RSS feed by default is impossible. My advice would be to find the permalink in the RSS feed and use an API call to return the corresponding key for a reblog.
There is a way to construct the reblog URL manually, if you have access to the post’s HTML page:
search for rk= in the HTML source code (it's in the block opened by <!-- BEGIN TUMBLR CODE -->)
copy the value of this parameter (e.g. "1234" if you find rk=1234)
now manipulate the URL:
append this value at the URL (add a slash before it, if there is none) (you can replace the slug with the value, if available)
replace "post" with "reblog"
remove the subdomain
call this crafted URL
This rk value (maybe "reblog key"?) doesn’t seem to be included in the feed.

Do *.zcml files get parsed i18n wise?

I have named utilities and would like to mark names for later i18n usage. Is this the right way?
<utility
name="Home"
i18n:attributes="name"
provides=".interfaces..."
factory=".shortcut...." />
The utility's name is not a translatable message id, but an internal technical id. You cannot use it for translation purposes.
If you look at zope.component.zcml you can see the interface for the directive containing:
class IUtilityDirective(IBasicComponentInformation):
"""Register a utility."""
name = zope.schema.TextLine(
title=_("Name"),
description=_("Name of the registration. This is used by"
" application code when locating a utility."),
required=False)
If you look at for example http://wiki.zope.org/zope3/zcml.html it will tell you that an attribute needs to be of type MessageID to be translatable in ZCML.
If you have a ZCML directive with an attribute of type MessageID, all you need to do is to define an i18n:domain for the ZCML file. The ZCML machinery knows what attributes are translatable itself based on them being of the right type. So you don't need any extra markup to note any attributes like you need in TAL.
All that said, if you work inside Plone and use i18ndude to extract messages, it won't extract any messages from ZCML files - simply because there's not a single message being defined in ZCML, that's also actually shown anywhere in the Plone UI.
If you have utilities and want to give them translatable names, give them a title attribute, like:
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('mydomain')
class MyShortCut(object):
title = _('My shortcut')
and use the title attribute in the UI.
You do not want to do that. The name attribute is meant for application use, not end-users, and needs to be stable.
If you translate it, then you'll have to translate all named look-ups through-out your code too!
Titles and descriptions can be translated, using the i18n_domain="domain" marker on the <configure> element.

Resources