4

複数行フィールドでリッチ テキスト形式が有効になっているかどうかをコア サービスで確認したい。

リッチテキスト形式を有効にした後にスキーマのソースを分析すると、この目的のために挿入されたタグがたくさんあります:-

  <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;
    }
}

提案してください。

4

2 に答える 2

9

代わりに、「is」チェックを変更してXhtmlFieldDefinitionDataと比較してください。

if (field is XhtmlFieldDefinitionData)
{
   ...
}
于 2012-10-16T12:44:55.963 に答える
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);
于 2012-10-16T12:41:03.640 に答える