我想在一個Tridion模式中應用一些額外的過濾xslt。對RTF字段的模式源應用限制
我有一個名爲「圖像」的字段。這是一個RTF,它已被配置爲允許通過在編輯格式化功能下選擇圖像和超鏈接。
它背後的想法是在RTF中插入圖像並將其作爲RTF字段。
樣品有效的源:
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>
由於RTF是允許超鏈接和圖像可能有機會,用戶可以不同的格式輸入它們。 無效:
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>
規則:
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.
我知道這可能使用事件系統來完成。但我仍然想通過應用XSLT過濾來實現。
XSLT過濾來源:
<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()]) )]) ]">
<!-- 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>
<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>
我想知道,我是否可以通過寫一些醫藥XSLT代碼做到這一點:架構源的FilterXSLT。
任何人都可以幫助如何做到這一點。
謝謝。
考慮組件鏈接作爲一種替代方法,因爲它提供了有效的模式和包裹鏈接標記控制(通過模板代碼)。 ''應該指向什麼?您可以在另一個組件,多媒體元數據或可能使用自定義鏈接類型的GUI擴展中管理超鏈接(和其他元數據)。 –