2012-10-16 65 views
4

如果在多行字段上啓用富文本格式,我想檢查覈心服務。Tridion核心服務:如何檢查多行字段是否啓用了豐富的文本格式?

如果我後富文本格式,可以實現分析模式的來源,然後有很多的標籤插入用於此目的: -

<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"> 
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
       <xsl:output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></xsl:output> 
       <xsl:template name="FormattingFeatures"> 
       <FormattingFeatures xmlns="http://www.tridion.com/ContentManager/5.2/FormatArea"> 
        <Doctype>Transitional</Doctype> 
        <AccessibilityLevel>0</AccessibilityLevel> 
        <DisallowedActions></DisallowedActions> 
        <DisallowedStyles></DisallowedStyles> 
       </FormattingFeatures> 
       </xsl:template> 
       <xsl:template match="/ | node() | @*"> 
       <xsl:copy> 
        <xsl:apply-templates select="node() | @*"></xsl:apply-templates> 
       </xsl:copy> 
       </xsl:template> 
       <xsl:template match="/body[not(processing-instruction() or comment() or normalize-space(translate(., &apos; &apos;, &apos;&apos;)) != &apos;&apos; or  *[@* or * or comment() or processing-instruction() or not(self::p or self::br)])]"> 
       <!-- make an empty <body> if all the body has is empty paragraphs, line-breaks and (non-breaking) spaces --> 
       <xsl:copy></xsl:copy> 
       </xsl:template> 
       <xsl:template match="p[not(@* or * or comment() or processing-instruction() or normalize-space(translate(., &apos; &apos;, &apos;&apos;)) != &apos;&apos; or  following-sibling::node()[@* or * or comment() or processing-instruction() or not(self::p or self::text()) or normalize-space(translate(., &apos; &apos;, &apos;&apos;)) != &apos;&apos;])]"> 
       <!-- ignore all paragraphs at the end that have nothing but (non-breaking) spaces --> 
       </xsl:template> 
      </xsl:stylesheet> 
      </tcm:FilterXSLT> 

但是這恰恰是物業找到如果富文本啓用了我即使在覈心服務API文檔中也無法弄清楚。

我的核心服務代碼有點象下面這樣: -

SessionAwareCoreService2010Client client = new SessionAwareCoreService2010Client(); 
client.ClientCredentials.Windows.ClientCredential.UserName = "myUserName"; 
client.ClientCredentials.Windows.ClientCredential.Password = "myPassword"; 
client.Open(); 
SchemaFieldsData fields = client.ReadSchemaFields("tcm-x-y-z", 
                true, new ReadOptions()); 


foreach (var field in fields.Fields) 
{ 
    if (field is MultiLineTextFieldDefinitionData) 
    { 
     return Constants.DataType.STRING; 
    } 
} 

請建議。

回答

2

您可以使用標準GetType().Name

var schemaFields = ClientAdmin.ReadSchemaFields("tcm:2-82-8", false, new ReadOptions()); 
var field = schemaFields.Fields.First(); 
Assert.AreEqual("XhtmlFieldDefinitionData", field.GetType().Name); 
9

只要改變你的 「是」 檢查與XhtmlFieldDefinitionData而不是比較:

if (field is XhtmlFieldDefinitionData) 
{ 
    ... 
} 
相關問題