Two hyphens in an asset title breaks a format
I have an index block that generates the following output:
<system-page id="d255f1778072701764c820a6aad69371">
<name>arboretum-spring-sale</name>
<is-published>true</is-published>
<last-published-on>1459524410436</last-published-on>
<last-published-by>stephens</last-published-by>
<title>Arboretum holds Spring Plant Sale on Saturday, April 9</title>
<summary>Annual sale offers a wide range of colorful, water-wise plants from Australia, New Zealand, South Africa, and California.</summary>
<keywords>UC Santa Cruz Arboretum, UCSC Arboretum, Spring Plant Sale</keywords>
<start-date>1459494000000</start-date>
<display-name>Arboretum holds Spring Plant Sale on Saturday, April 9</display-name>
<path>/2016/04/arboretum-spring-sale</path>
<site>news</site>
<link>site://news/2016/04/arboretum-spring-sale</link>
<created-by>stephens</created-by>
<created-on>1459522759785</created-on>
<last-modified-by>stephens</last-modified-by>
<last-modified>1459524390111</last-modified>
</system-page>
I'm using the following format to create a JSONP file:
<xsl:template match="system-page">
<xsl:text>{"name": "</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>", "title": "</xsl:text>
<xsl:value-of select="title"/>
<xsl:text>", "url": "</xsl:text>
<xsl:text>http://news.ucsc.edu</xsl:text>
<xsl:value-of select="path"/>
<xsl:text>.html</xsl:text>
<xsl:text>", "date": "</xsl:text>
<xsl:call-template name="format-date">
<xsl:with-param name="date" select="start-date"/>
<xsl:with-param name="mask">mmmm dd, yyyy</xsl:with-param>
</xsl:call-template>
<xsl:if test="system-data-structure/lead-image/image/path != '/'">
<xsl:text>", "thumbnail": "</xsl:text>
<xsl:text>http://news.ucsc.edu</xsl:text>
<xsl:value-of select="system-data-structure/lead-image/image-thumb/path"/>
</xsl:if>
<xsl:text>"}</xsl:text>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:template>
If the title
element in the index block has two
hyphens in it, the format doesn't work and I get a blank screen. If
I remove the two hyphens from the title, it works again. I'm
stumped as to why.
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Rob Knight on 01 Apr, 2016 05:21 PM
Zip file of both files attached.
2 Posted by Ryan Griffith on 01 Apr, 2016 05:44 PM
Hi Rob,
The issue is that
--
is not valid XML, so the page rendering is failing.Your best bet would be to remove the double hyphen so you can output the value correctly. The best option I can think of is to use a Xalan function to replace double hyphens with a single one. Such a function would look something like:
3 Posted by Rob Knight on 01 Apr, 2016 06:20 PM
Thank you for your prompt reply, Ryan! The double hyphen is meant to mimic an mdash. Out of curiosity, is there any way to get something like an mdash in a title? It seems like I cannot use the HTML entity code for it.
4 Posted by Rob Knight on 01 Apr, 2016 06:25 PM
Never mind. I see that the UTF character code works in titles.
5 Posted by Ryan Griffith on 01 Apr, 2016 08:28 PM
You got it, Rob. You should be able to use the numeric entity to render an mdash. To confirm, were you able to get things working?
Please let me know if you have any questions.
Thanks!
6 Posted by Rob Knight on 03 Apr, 2016 09:10 PM
Do Xalan components need to be enabled in preferences or anything like that? I've tried to code above and it doesn't work. It fails silently with no error message, similar to my original script.
7 Posted by Rob Knight on 03 Apr, 2016 09:14 PM
I see that they do. We have them enabled in our setup, so I'm not sure why it isn't working.
8 Posted by Ryan Griffith on 04 Apr, 2016 12:33 PM
Hi Rob,
Correct, there is an Enable Xalan JavaScript system preference you will want to ensure is checked.
If it is not working, please feel free to attach your Format and sample XML that is being applied to the Format and I would be happy to help take a closer look.
Thanks!
9 Posted by Rob Knight on 04 Apr, 2016 04:34 PM
Here is my XML:
And my XSL format:
10 Posted by Ryan Griffith on 05 Apr, 2016 02:00 PM
Hi Rob,
Unfortunately, I was not able to reproduce the issue in my test instance. After adding a double-hyphen to the sample XML you provided, I was getting the following which appears to be the expected output:
I also tried attaching the XML Block and Format to a page to make sure it renders and it does.
Please let me know if you have any questions.
Thanks!
Tim closed this discussion on 25 May, 2016 05:30 PM.