Changing XML Code Folding in ACE Editor - editor

The current code-folding behavior of the ACE editor is to fold XML from:
<TAG DATA=FOO DATA=BAR>
<blah>
</TAG>
into: <tag ... </tag>
How can I get it instead to do something more along the lines of:
<tag data=foo data=bar> ... </tag>
IE, I want to keep the attributes of the starting tag unfolded. Is there an easy way to do this? What files should I be editing?
Thanks!

Related

What is the structure of wikipedia dumps?

I need the list of Hungarian words for a project and the only possible source I found is wikipedia XML dumps. They are really big, I guess I could parse them with a read stream and a SAX parser, but it would be nice to know more about the structure so I could test the code on a small example before running it on the big files. Is there a description somewhere about what structure they use and what the different XML gzip files contain? https://dumps.wikimedia.org/enwiki/latest/ https://dumps.wikimedia.org/huwiki/latest/
The format is documented here: https://www.mediawiki.org/wiki/Help:Export It looks like this:
<mediawiki xml:lang="en">
<page>
<title>Page title</title>
<restrictions>edit=sysop:move=sysop</restrictions>
<revision>
<timestamp>2001-01-15T13:15:00Z</timestamp>
<contributor><username>Foobar</username></contributor>
<comment>I have just one thing to say!</comment>
<text>A bunch of [[Special:MyLanguage/text|text]] here.</text>
<minor />
</revision>
<revision>
<timestamp>2001-01-15T13:10:27Z</timestamp>
<contributor><ip>10.0.0.2</ip></contributor>
<comment>new!</comment>
<text>An earlier [[Special:MyLanguage/revision|revision]].</text>
</revision>
</page>
<page>
<title>Talk:Page title</title>
<revision>
<timestamp>2001-01-15T14:03:00Z</timestamp>
<contributor><ip>10.0.0.2</ip></contributor>
<comment>hey</comment>
<text>WHYD YOU LOCK PAGE??!!! i was editing that jerk</text>
</revision>
</page>
</mediawiki>

How to extend felogin's locallang?

How is it possible to add translations of strings to the felogin plugin? I slowly start to get the convention for templates (directing to the modified templates in the plugin's typoscript configuration) but that does not work with the locallang. The original messages are in English in the xlf format, located in the plugin's folder. I know this can be done in TypoScript but I do not like to have the strings defined so incosistently. (I guess modifying that original file is not the proper way.)
Overriding labels by TypoScript is the way to go. Manually editing the l10n files is a really bad idea - these files are overwritten on updating the translations. If the extension gets an update and new labels are added, you will want to perform the updates.
The change from XML files for translation to the XLIFF format didn't change anything in the best practise you should use for adjusting labels according to your needs. It's just another format with a standardized translation server (Pootle) that (in theory) allows some special features like e.g. plural forms.
Conclusion: Use TypoScript.
For the default language (no config.language set) use:
plugin.tx_felogin_pi1._LOCAL_LANG.default {
key = value
}
For a specific language, e.g. German, use
plugin.tx_felogin_pi1._LOCAL_LANG.de {
key = value
}
The best way is to use the following code:
ext_tables.php, e.g. of your theme extension with
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:felogin/Resources/Private/Language/locallang.xlf'][] = 'EXT:theme/Resources/Private/Language/locallang_felogin.xlf';
and in this file you can use something like
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2015-06-30T21:14:27Z">
<header>
<description>Language labels for felogin</description>
</header>
<body>
<trans-unit id="permalogin">
<source>An diesem Rechner angemeldet bleiben</source>
</trans-unit>
<trans-unit id="ll_forgot_header">
<source>Passwort vergessen?</source>
</trans-unit>
<trans-unit id="ll_welcome_header">
<source>Sie betreten den Händlerbereich</source>
</trans-unit>
<trans-unit id="ll_welcome_message">
<source>Bitte loggen Sie sich ein.</source>
</trans-unit>
</body>
</file>
</xliff>
You can use the BE language module to download preconfigured locallangs for every language you need.
The files are stored in e.g. typo3conf/l10n/de/fe_login.
You can edit these files manually in l10n to get your own strings inside or use an extension like snowbabal to do the editing inside a BE module.

Custom taglib results in MethodNotFoundException

What I want to do is declare a common datatable header as a composite component. But this answer set me straight since it was not rendered:
How to create a composite component for a datatable column?
Basically it instructed me to try my own taglib and this works really well except my header has a link in it that does reRender. When this link is pressed MethodNotFoundException is thrown.
This is my custom taglib:
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://stackoverflowdummy.com/dumb/components</namespace>
<tag>
<tag-name>tableHeader</tag-name>
<source>tags/tableHeader.xhtml</source>
<attribute>
<description></description>
<name>value</name>
</attribute>
<attribute>
<description>The listener that handles sorting</description>
<name>sortAction</name>
<method-signature>java.lang.String action()</method-signature>
</attribute>
<attribute>
<description>The property that holds the current id to sort on
</description>
<name>sortValue</name>
</attribute>
<attribute>
<description>The component that needs to be updated after changes
</description>
<name>reRender</name>
</attribute>
</tag>
</facelet-taglib>
I tried without method-signature and I also tried removing "action". My web.xml does include the taglib like this:
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/cc.taglib.xml</param-value>
</context-param>
I also tried with "facelets.LIBRARIES" but it made no difference.
<h:commandLink value="#{o.label}" action="#{sortAction}" immediate="true" reRender="#{reRender}">
<f:setPropertyActionListener target="#{sortValue}" value="#{o.column.sortId}" />
</h:commandLink>
End usage is defined like this:
sortAction="#{myBean.sort}"
That bean has a method called with signature String sort(); and it works really well if I just define it and skip using my own tag. However everything works with the tag except the action method...
The JavaBean Specification gives multiple ways on how to call a method. In fact, you can call a action the normal way #{actionBean.actionMethod}, but also the way #{actionBean['actionMethod']}.
The sorting Action you are giving is transferred as a MethodExpression, which compared to ValueExpressions gave me problems in some JSF Environments.
What I'd like you to try testwise is, to give the action as two separate (value) parameters:
sortActionBean="#{myBean}"
sortActionMethod="sort"
and call those in the template as #{sortActionBean['sortActionMethod']}. A good article on this topic is Passing action methods facelets tags.
Hope it helps...

Extracting data from xml file using xmllint

I have a small xml document from which I need to extract some values using xmllint. I am able to navigate through the xml hierarchy using xmllint --shell xmlfilename command.
But I am unable to extract the values. I don't want to use a grep / any pattern matching command, as that is already done and is a success.
I would appreciate any help regarding the xmlliint.
Here is my document in png format. I want to extract the 300$ and 500$ (the value).
<?xml version="1`.`0" encoding="ISO-8859-1"?>
<adi>
<asset>
<electronics item="Mobile" name="Nokia" value="300$" />
<electronics item="Mobile" name="Sony" value="500$" />
</asset>
</adi>
Another doubt is, are the two sets, the different representation of same xml ?
<?xml version="1.0 encoding="ISO-8859-1"?>
<adi>
<asset>
<electronics>
<item> Mobile </item>
<name>Nokia</name>
<value>300$</value>
</electronics>
<electronics>
<item> Mobile </item>
<name>Sony</name>
<value>500$</value>
</electronics>
</asset>
</adi>
With regards to your second question, those two snippets do not represent the same XML content. Attributes and child elements are not equivalent. A child element can be the root element of some arbitrary XML tree, but attributes are atomic.
E.g., I could modify the second snippet like this:
<?xml version="1.0 encoding="ISO-8859-1"?>
<adi>
<asset>
<electronics>
<item>
Mobile
<sub-item>Phone</sub-item>
</item>
<name>Nokia</name>
<value>300$</value>
</electronics>
<electronics>
<item> Mobile </item>
<name>Sony</name>
<value>500$</value>
</electronics>
</asset>
</adi>
where I have added <sub-item>Phone</sub-item> to the first <item> element.
However, there's no equivalent if item is an attribute instead, as in the first snippet.
Late but while searches for the tag xmllint match the first page, I answer you now ;)
use --xpath instead of --xpath like below
xmllint --xpath '//electronics/value/text()' second-xml_file.xml

XSLT append URL from relative to absolute

In my XML document, I am pulling the content of a <TextBlock> that contains images. The XML shows:
<img src="/templates_soft/images/facebook.png" alt="twitter" />
When I view the page, the image doesn't show up because it is not at the same path as the original page.
I need to add the rest of the URL for the images to display. Something like http://www.mypage.com/ so that the image displays from http://www.mypage.com/templates_soft/images/facebook.png
Is there a way to do this?
Use:
<img src="{$imageBase/}templates_soft/images/facebook.png" alt="twitter" />
where the xsl:variable named $imageBase is defined to contain the necessary prefix (in your case "http://www.mypage.com").
Here is a complete XSLT solution:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="pimageBase" select="'http://www.mypage.com'"/>
<xsl:template match="img">
<img src="{concat($pimageBase, #src)}" alt="{#alt}"/>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on the following XML document:
<img src="/templates_soft/images/facebook.png" alt="twitter" />
the wanted, correct result is produced:
<img src="http://www.mypage.com/templates_soft/images/facebook.png" alt="twitter"/>
If you go with XSLT, you simply create an XML that contains the entire URL as you desire, you then tag the XSLT up so it contains the "pointers" to the original fields in the XML file. If you are binding to a control, like a Grid, you can row bind and add the information at that point, if it is easier for you to do than XSLT.

Resources