I want to apply some additional xslt filtering in one Tridion schema.
I have a field named "image". This is RTF, it is configured to allow images and hyperlinks, selecting them when editing formatting functions.
The idea is to insert both the image into the RTF and make it like an RTF field.
sample Valid source:
1.<a title="google site" href="http://google.com"><img style="width: 141px; height: 167px;" alt="Image" title="Image" src="tcm:202-11587"/></a> 2.<a title="Internal link" href="tcm:202-9720"><img style="width: 141px; height: 167px;" alt="Image" title="Image" src="tcm:202-11587"/></a>
Since RTF allows you to use a hyperlink and an image, perhaps the user can enter them in different formats. Invalid:
1.<a title="google site" href="http://google.com"></a> <img style="width: 141px; height: 167px;" alt="Image" title="Image" src="tcm:202-11587"/> 2.<img style="width: 141px; height: 167px;" alt="Image" title="Image" src="tcm:202-11587"/> <a title="google site" href="http://google.com"></a> 3.<a title="google site" href="http://google.com"><img style="width: 141px; height: 167px;" alt="Image" title="Image" src="tcm:202-11587"/></a> <a title="Internal link" href="tcm:202-9720"><img style="width: 141px; height: 167px;" alt="Image" title="Image" src="tcm:202-11587"/></a>
Rules:
1.Only one Image should be allowed and it should be hyperlink. 2.There should be one <img> tag wrapped by one <a> tag. 3. Multiple images are not allowed.
I know that this can be done using an event system. But still, I was thinking about implementation using XSLT filtering.
XSLT Filter Source:
<xsd:element name="image" minOccurs="0" maxOccurs="1" type="tcmi:XHTML"> <xsd:annotation> <xsd:appinfo> <tcm:ExtensionXml xmlns:tcm="http://www.tridion.com/ContentManager/5.0"></tcm:ExtensionXml> <tcm:Size xmlns:tcm="http://www.tridion.com/ContentManager/5.0">2</tcm:Size> <tcm:FilterXSLT xmlns:tcm="http://www.tridion.com/ContentManager/5.0"> <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform"> <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(., ' ', '')) = '' 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(., ' ', '')) = '' and not(@*) and not(processing-instruction()) and not(comment()) and not(*[not(self::br) or @* or * or node()]) )]) ]"> </template> <template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]"> <text> </text> </template> <template name="FormattingFeatures"> <FormattingFeatures xmlns="http://www.tridion.com/ContentManager/5.2/FormatArea" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <Doctype>Transitional</Doctype> <AccessibilityLevel>0</AccessibilityLevel> <DisallowedActions> <Bold></Bold> <Italic></Italic> <Underline></Underline> <Strikethrough></Strikethrough> <Subscript></Subscript> <Superscript></Superscript> <AlignLeft></AlignLeft> <Center></Center> <AlignRight></AlignRight> <Bullets></Bullets> <Numbering></Numbering> <IndentDecrease></IndentDecrease> <IndentIncrease></IndentIncrease> <Font></Font> <Background></Background> <InsertCharacter></InsertCharacter> <Anchor></Anchor> <Table></Table> <TableWidth></TableWidth> <TableHeight></TableHeight> <TableCellSpacing></TableCellSpacing> <TableCellPadding></TableCellPadding> <TableHAlign></TableHAlign> <TableBorderSize></TableBorderSize> <TableBorderStyle></TableBorderStyle> <TableBorderColor></TableBorderColor> <TableBackground></TableBackground> <TableCellWidth></TableCellWidth> <TableCellHeight></TableCellHeight> <TableCellHAlign></TableCellHAlign> <TableCellVAlign></TableCellVAlign> <TableCellBackground></TableCellBackground> <HLine></HLine> <SectionType></SectionType> <H1></H1> <H2></H2> <H3></H3> <H4></H4> <H5></H5> <H6></H6> <Style></Style> <Language></Language> <Abbreviation></Abbreviation> <CurrentElement></CurrentElement> </DisallowedActions> <DisallowedStyles></DisallowedStyles> </FormattingFeatures> </template> </stylesheet> </tcm:FilterXSLT> </xsd:appinfo> </xsd:annotation> </xsd:element>
I want to know if I can do this by writing some xslt code in tcm: FilterXSLT of the schema source.
Can anyone help how to do this.
Thanks.
source share