2

I have a component with a rich text field.

In the Source tab I type the following code.

enter image description here

then I switch to the Design tab and then I switch to the Source tab and

The HTML tag (<head>, <html>, <meta>, <title>, <body>, <link>) is disappeared and added <![CDATA[]]> sign.

(Please refer to the following image.)

enter image description here

But I want to permit any HTML Tag. (I don't strict any HTML Tag.)

The configuration of rich text field is described below.

Document Type: Transitional

Accessibility Level: None

Filtering XSLT is described below.

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<output omit-xml-declaration="yes" indent="yes"></output>
<strip-space elements="*"></strip-space>
<template match="node()|@*">
    <copy>
        <apply-templates select="node()|@*"></apply-templates>
    </copy>
</template>

I think that the above Filtering XSLT configuration is wrong, maybe.

But I don't know where is wrong.

So, please tell me how to configurate the Filtering XSLT.

UPDATE

I modify the above Filtering XSLT configuration as described below. But my problem is not soloved.

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></output>
<template match="html">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="body">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="head">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="title">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="meta">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="link">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="script">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="body">
    <apply-templates select="node() | @*"></apply-templates>
</template>
<template match="/ | node() | @*">
    <copy>
        <apply-templates select="node() | @*"></apply-templates>
    </copy>
</template>
<template match="*[      (self::br or self::p or self::div)     and      normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     and      not(@*)     and      not(processing-instruction())     and      not(comment())     and      not(*[not(self::br) or @* or * or node()])     and      not(following::node()[not(         (self::text() or self::br or self::p or self::div)        and         normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        and         not(@*)        and         not(processing-instruction())        and         not(comment())        and         not(*[not(self::br) or @* or * or node()])       )])     ]">
    <!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks -->
</template>
<template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
    <!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space -->
    <text> </text>
</template>

3
  • This is not an answer... but the real reason why it gets removed is that 1) Tridion RTF is originally expected to be XHTML and 2) XHTML does not allow those tags within a body tag. Given that Tridion expects RTF to be content to be used within the body tag, those elements get removed (they're invalid according to the XHTML schema)
    – Nuno Linhares
    Apr 9, 2014 at 1:22
  • @ Nuno Linhares.... Thank you for answer my question. i see. Judge from your comment, I think i can't solve my problem.
    – Arai Yuhei
    Apr 9, 2014 at 3:35
  • It might be possible by fiddling with the Xhtml.Config. I can't try it now
    – Nuno Linhares
    Apr 9, 2014 at 3:45

2 Answers 2

1

To elaborate on Nuno's comment (which is an answer in my opinion), an RTF field is stored as XHTML, so everything allowed in there must be HTML/XHTML compliant.

You are trying to save an entire XHTML document including a document descriptor. While that is of course HTML/XHTML compliant, it is not valid in the context. SDL Tridion expects the contents of a RTF field (or format area) to be whatever you place inside the BODY tag of an HTML document, so it has a set of allowed elements and attributes.

You can extend all your RTF fields to allow additional element and attributes, via the file TcmXhtml.Config under ..\Tridion\web\WebUI\Core\Controls\FormatArea\TcmXhtml. But I don't think you can set it to allow an entire (X)HTML document like you tried.

So onwards to a possible solution, I wouldn't spend too much time trying to save the full HTML document in the source tab, just look for other options. Why do you need the full XHTMl document in there, isn't it enough to have a Page Template generate the HTML, HEAD and BODY elements and only place all your content inside the BODY element in your RTF field?

Or if you do require a full XHTML document to be stored, you can consider creating a Complex Schema which defines your XHTML. But I think you might be spending more time on getting that to work than you would when you change your requirements a little. That being said, I have no clue as to why you have these requirements, so also I'm unable to validate if they are indeed supported by a valid use case or if you might be misinterpreting your available options.

1
  • Thank you for answer my question. Simply I try to confirm whether I can register <html>, <title>, <meta> ...etc on RTF. This is not requirement but I want to confirm whether I can register the above tag. I know I can register <Script> tag on RTF. But Script code is converted <![CDATA[Script code]]>, I know.
    – Arai Yuhei
    Apr 10, 2014 at 0:54
0

We use this XSLT for HTML in rich text, maybe could be useful for you. (transitional and WCAG2)

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></output>
<template match="/ | node() | @*">
    <copy>
        <apply-templates select="node() | @*"></apply-templates>
    </copy>
</template>
<template match="*[      (self::br or self::p or self::div)     and      normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     and      not(@*)     and      not(processing-instruction())     and      not(comment())     and      not(*[not(self::br) or @* or * or node()])     and      not(following::node()[not(         (self::text() or self::br or self::p or self::div)        and         normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        and         not(@*)        and         not(processing-instruction())        and         not(comment())        and         not(*[not(self::br) or @* or * or node()])       )])     ]">
    <!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks -->
</template>
<template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
    <!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space -->
    <text> </text>
</template>

2
  • Sorry ... you need to add HTML and head to make it work, some like : <template match="html"> <apply-templates select="node() | @*"></apply-templates> </template> or use a simple text (not rich text) Apr 8, 2014 at 10:16
  • @ Julián Hernández ... Thank you for answer my question. I try your solution. But my problem is not solved.
    – Arai Yuhei
    Apr 9, 2014 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.