[英]Creation of Schema using Core Service in SDL Tridion 2011 SP1
I am creating Schema using Core Service in SDL Tridion 2011 SP1.我正在使用 SDL Tridion 2011 SP1 中的核心服务创建架构。 In the creation of the Schema I have used the custom namespace URI for the Schema.
在创建架构时,我为架构使用了自定义命名空间 URI。 Generally when we create a Schema through Tridion CME directly, we will get a namespace URI generated automatically starting with
uuid:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
一般我们直接通过Tridion CME创建Schema的时候,会得到一个自动生成的
uuid:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I have used this code to create a Schema:我使用这段代码创建了一个架构:
Tridion.ContentManager.CoreService.Client.SchemaData schemas = new SchemaData
{
Title = "coreservicesschema3",
Description = "coreservicesschema",
Id = "tcm:0-0-0",
LocationInfo = new LocationInfo
{
OrganizationalItem =
new LinkToOrganizationalItemData { IdRef = "tcm:7-18-2" }
},
RootElementName = "Content",
NamespaceUri = "customnamespaceuri",
Xsd = xsd.ToString(SaveOptions.None)
};
schemas = (SchemaData)client.Create(schemas, new ReadOptions());
Response.Write("<BR>" +"new schema id"+ schemas.Id);
Response.Write("<BR>" + "new schema Name" + schemas.Title);
//schema created
Can anyone indicate how to create a Schema with default namespace URI?谁能指出如何使用默认名称空间 URI 创建架构?
Thank you谢谢
The minimal code you need in order to create a Schema with Core Service is the following:使用核心服务创建模式所需的最少代码如下:
using (var client = new SessionAwareCoreServiceClient(netTcpBinding, remoteAddress))
{
SchemaData schemaData = client.GetDefaultData(ItemType.Schema, folderId) as SchemaData;
schemaData.Description = "description";
schemaData = client.Save(schemaData, readOptions) as SchemaData;
schemaData = client.CheckIn(schemaData.Id, readOptions) as SchemaData;
Console.WriteLine("Schema: " + schemaData.LocationInfo.WebDavUrl);
}
The Schema will be created with the default namespace.将使用默认命名空间创建架构。 In the case of this example, it will also not contain any fields, but that's not what you were asking for.
在本示例中,它也不包含任何字段,但这不是您所要求的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.