Diazo and xslt "call-template" - plone

I'm trying to use the xslt "call-template" directive in my diazo rules, cause I don't want "repeat my self".
But, when I set-up the xsl:template and call it with xsl:call-template in the rules I obtain an exception from the diazo debugger
element template only allowed as child of stylesheet
What's the matter? Can I use the call-tempalte? And if not, how I can don't repeat my self in the xslt templating?
Example:
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- indent and strip space for pretty output -->
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<theme href="index.html" />
<after css:theme-children="body">
<xsl:call-template name="hello"></xsl:call-template>
</after>
<xsl:template name="hello">
<xsl:element name="div">
Hello!
</xsl:element>
</xsl:template>
</rules>
I found that diazo could be manage this in a file defined as xsl:stylesheet (https://github.com/plone/diazo/blob/master/lib/diazo/normalize-rules.xsl) rather directly in the rules, but how manage this in my add-on package?
Thank's

If you still have this issue, try the most recent versions of Diazo and plone.app.theming.
I cannot reproduce this issue with the latest versions (on Plone 4.3.3). For me, your rules example works just fine (as long as they are in the main [not rules file).

Related

JavaFX Program isnt working when trying to compile with FXML-File [duplicate]

This error,
The processing instruction target matching "[xX][mM][lL]" is not allowed
occurs whenever I run an XSLT page that begins as follows:
<?xml version="1.0" encoding="windows-1256"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="../header.xsl"/>
<xsl:template match="/">
<xsl:call-template name="pstyle"/>
<xsl:call-template name="Validation"/>
<xsl:variable name="strLang">
<xsl:value-of select="//lang"/>
</xsl:variable>
<!-- ////////////// Page Title ///////////// -->
<title>
<xsl:value-of select="//ListStudentFinishedExam.Title"/>
</title>
Note: I removed any leading spaces before the first line, but the error still occurs!
Xerces-based tools will emit the following error
The processing instruction target matching "[xX][mM][lL]" is not allowed.
when an XML declaration is encountered anywhere other than at the top of an XML file.
This is a valid diagnostic message; other XML parsers should issue a similar error message in this situation.
To correct the problem, check the following possibilities:
Some blank space or other visible content exists before the <?xml ?>
declaration.
Resolution: remove blank space or any other
visible content before the XML declaration.
Some invisible content exists before the <?xml ?>
declaration. Most commonly this is a Byte Order Mark
(BOM).
Resolution:
Remove the BOM using techniques such as those suggested by the W3C
page on the BOM in HTML.
A stray <?xml ?> declaration exists within the XML content.
This can happen when XML files are combined programmatically or
via cut-and-paste. There can only be one <?xml ?> declaration
in an XML file, and it can only be at the top.
Resolution: Search for
<?xml in a case-insensitive manner, and remove all but the top XML
declaration from the file.
Debug your XML file. Either there is space or added extra or fewer tags.
For better understanding build the project through the command line. Windows: gradlew build
In my case, AndroidManifest.xml has a blank space at the very first line
<Empty Row> // This Creates the issue
<?xml version="1.0" encoding="utf-8"?>
There was auto generated Copyright message in XML and a blank line before <resources> tag, once I removed it my build was successful.
just remove this line: <?xml version="1.0" encoding="utf-8"?> because this kind of error only come because of this line or you might also check the format of your line according the mentioned line in this answer.
I had a similar issue with 50,000 rdf/xml files in 5,000 directories (the Project Gutenberg catalog file). I solved it with riot (in the jena distribution)
the directory is cache/epub/NN/nn.rdf (where NN is a number)
in the directory above the directory where all the files are, i.e. in cache
riot epub/*/*.rdf --output=turtle > allTurtle.ttl
This produces possibly many warnings but the result is in a format which can be loaded into jena (using the fuseki web interface).
surprisingly simple (at least in this case).
Another reason of the above error is corrupted jar file. I got the same error but for Junit when running unit tests. Removing jar and downloading it again fixed the issue.
in my case was a wrong path in a config file: file was not found (path was wrong) and it came out with this exception:
Error configuring from input stream. Initial cause was The processing
instruction target matching "[xX][mM][lL]" is not allowed.
For PHP, put this line of code before you start printing your XML:
while(ob_get_level()) ob_end_clean();
It's worth checking your server's folders to see if there's a stray pom.xml hanging around.
I found that I had the problem everyone else described with a malformed pom.xml, but in a folder that I didn't expect to be on the server. An old build was sticking around unwelcome D:
For my case, the tab is the trouble maker. Replace the tab with blank should resolve the issue

RSS '<link>' Tag in Jade

For my blog site, I use Node.js, Express, and Jade for templating.
I built a simple rss.jade template for my RSS feed, and am having problems getting the required tag to work nicely.
I believe, in older versions of Jade you could use:
link http://example.com
Now, it is enforcing that 'link' is self-closing like:
link(rel='stylesheet', href='style.css')
Is there any other solution rather than plain-text like:
|<link>http://example.com</link>
Are you sure you defined the right doctype?
With the doctype xml you can produce this example:
doctype xml
rss(version="2.0")
link.
http://example.com
and get the output you wished to see:
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<link>http://example.com</link>
</rss>

XSLTApplyError: xsl:comment : '--' or ending '-' not allowed in comment

I am really new to plone and diazo so forgive me if the answer to question is too obvious.
I was asked to create a diazo theme for a website running on plone. Right now i'm at a state where i where i think the theme is reasonably complete(without rules) and i uploded it via .zip to the plone planing to create the rules in plones rules editor. Made a handful of them and hit the preview button to see whether what i am doing is even repotely going into the right direction but hat it showed was this error.
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module plone.app.theming.browser.mapper, line 245, in getFrame
Module lxml.etree, line 567, in lxml.etree.XSLT.__call__ (src/lxml/lxml.etree.c:124426)
XSLTApplyError: xsl:comment : '--' or ending '-' not allowed in comment
After spending quiet some time with a well known search engine i'm still uncertain if that is a mistake i made in the rules.xml or something the websites admin has to look at.
Any and all help will be appreciated.
Edit version information:
Plone 4.3 (4305)
CMF 2.2.7
Zope 2.13.19
Python 2.7.3 (default, Feb 4 2013, 09:04:32) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
PIL 1.7.8 (Pillow)
Edit rules so far
<?xml version="1.0" encoding="UTF-8"?>
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Apply the following rules to standard Plone pages -->
<rules css:if-content="#visual-portal-wrapper">
<theme href="theme.html" />
<!-- Replace title with Plone's page title -->
<replace css:theme="html head title" css:content="html head title" />
<!-- Copy base tag and script tags from Plone -->
<after css:theme-children="html head" css:content="html head base" />
<after css:theme-children="html head" css:content="html head script" />
<!-- Insert your own rules here -->
<!-- Replace logo with Plone's logo -->
<replace css:theme-children="a#brand img" css:content-children="a#portal-logo img"/>
<!-- Replace top navigation with Plone's top navigation -->
<replace css:theme-children="navbar" css:content-children="ul#portal-globalnav"/>
<!-- Replace search with Plone's search -->
<replace css:theme-children="input.search-query" css:content-children="input#searchGadget"/>
<!-- Replace top navigation with Plone's top navigation -->
<replace css:theme-children="documentDescription" css:content-children="documentDescription"/>
</rules>
</rules>
I didn't create that file myself. It was automatically created by plone upon uploading the .zip without a rules.xml in it. The four(that's how far I got until I first stumbled over the error) rules were created by plones editor.
At first I thought i messed up the comments somehow, seeing that is states "--" and "-" in the error message, but i couldn't find where and DW didn't point out any syntac errors either when opening the file in there.
Edit Solution:
Typo found in the theme.html . One comment ended on "->" instead of "-->" which i never new works for html in the first place.
There's some badly formed XML somewhere. It doesn't appear to be in your rules file. Check the theme file.
Every part of the Diazo processing is done with XML and XSLT processors that depend on the input being well-formed XML (or XSLT). That's just as true of the theme and content as of the rules file.
Content coming from Plone should be good XML (the HTML subset). Your rules file looks OK. That leaves the theme file as a candidate for the problem source.

XSLT image path is not working

I have a project which is structured as shown in image. This project sends emails out when reseting passwords. I have a folder XSLT with .xslt files in it. I have header, footer and style in Common folder where as ResetPassword.xslt right under XSLT folder.
ResetPassword.xslt:
<?xml version="1.0"?>
<xsl:include href="Common/Header.xslt"/>
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<xsl:call-template name="Style"/>
</head>
<body>
<table id="resetPasswordBody">
<tr>
<td>
<xsl:call-template name="Header"/>
As you can see I am calling the Header template from with in ResetPassword.xslt template. In the Header template I have following:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="Header">
<img src="img\banner.jpg"/>
</xsl:template>
</xsl:stylesheet>
The problem is when I run this project inside visual studio (by right click -> show in browser) the image does not appear. I am bit struggling to find out what path I can mention inside the header xslt template so that banner.jpg can appear. I have tried every possible combination.
The only path which works is the full path i.e. C:\XXXXXX\xxxxx
But the problem is when deployed on server the full path will not be a valid one.
I am confused and any help will be great.
Thanks in advance.
You are calling the file from template it is 2 up to reach the image
../../img/banner.jpg
or img/banner.jpg

RSS atom:link - Self reference doesn't match document location

I'm trying to create some valid RSS 2.0 data and I can't get the "atom:link" to validate.
Is it because I havent done the page yet, or is it because I have some invalid format?
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<atom:link href="http://www.lasseedsvik.se/rss" rel="self" type="application/rss+xml" />
<title>Test Test</title>
<link>http://www.lasseedsvik.se/rss</link>
<description>test</description>
<language>sv-se</language>
<item>
<title>test</title>
<link>
http://www.lasseedsvik.se/123
</link>
<guid>
http://www.lasseedsvik.se/123
</guid>
<description>
<![CDATA[test]]>
</description>
</item>
</channel>
</rss>
A link to the validator error page would be useful to help you debug this.
But I think you may need to put the version before the nanemspace declaration, like so:
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
The validator may also want to see an XML prolog. Maybe you have one and just did not include it in your example.
Note that no validator is perfect. The one at feedvalidator.org, for example, carps about perfectly valid feeds that don't implement "best practices" defined by the validator's creators. So, the most important thing is to make sure your feed is valid XML, then make sure it complies with the RSS 2.0 spec.

Resources