多数の ArcGIS アイテムのメタデータの編集

メタデータを作成すると、その中の情報が変更されます。1 つの ArcGIS アイテムに固有の情報であれば、そのメタデータを編集して情報を変更できます。ただし、変更した情報が多くの ArcGIS アイテムのメタデータに含まれる場合、影響を受けるすべてのアイテムのメタデータを手動で編集するプロセスには大きな労力を要します。

こうした状況に対処する最善のアプローチは、ユーザに代わって編集を実行できる XSLT スタイルシートを作成することです。[XSLT 変換] ツールでメタデータを編集するモデルを使用し、次に示すように、[メタデータ インポータ] ツールを使用して、編集した情報を ArcGIS アイテムにインポートして戻します。

XSLT スタイルシートを使ってメタデータを更新するためのジオプロセシング モデル。

メタデータを更新するための XSLT スタイルシートの作成

XSLT スタイルシートの作成方法の学習に役立つリソースは、インターネット上で数多く提供されています。ただし、次の例は初めて取り組むときに役立つものです。これらは、組織の連絡先情報を変更する方法を示しています。

元のメタデータに次のようなメタデータの連絡先が含まれていたとします。

組織の連絡先情報を更新する必要のあるメタデータ XML ドキュメントの抜粋です。

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <mdContact>
    <rpIndName>Reception</rpIndName>
    <rpOrgName>Esri Learning Center</rpOrgName>
    <rpCntInfo>
      <cntAddress>
        <delPoint>380 New York St.</delPoint>
        <city>Redlands</city>
        <adminArea>CA</adminArea>
        <postCode>92373</postCode>
        <country>US</country>
        <eMailAdd>info@esri.com</eMailAdd>
      </cntAddress>
      <cntPhone>
        <voiceNum>909-793-2853</voiceNum>
        <faxNum>909-793-4801</faxNum>
      </cntPhone>
    </rpCntInfo>
    <role>
      <RoleCd value="010"/>
    </role>
  </mdContact>
  ...
</metadata>

この連絡先情報の一部を次のように編集する必要があります。

上記以外の連絡先情報は変更しません。

次の XSLT スタイルシートがこれらの編集を実行します。名前のメタデータ エレメントは削除されます。アドレス全体が、すべての個別メタデータ エレメントとともに一度に更新されます。電話番号は他の電話情報とは別に更新されます。Web ページと連絡可能時間を追加するには、新しい情報を追加する前に、他の既存の連絡先情報をすべてコピーし、情報が失われないようにする必要があります。

組織の連絡先情報を編集し、他のすべてのメタデータ コンテンツをコピーする XSLT スタイルシート。

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no" />

  <!-- process the metadata using the templates below -->
  <xsl:template match="/">
    <xsl:apply-templates select="node() | @*" />
  </xsl:template>

  <!-- copy all metadata conent -->
  <xsl:template match="node() | @*" priority="0">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*" />
    </xsl:copy>
  </xsl:template>

  <!-- all metadata XSLT stylesheets used to update metadata should be identical to this example up to this point -->
  <!-- add the templates you'll use to update the metadata below -->

  <!-- remove the individual name from the contact information for the organization name Esri Learning Center -->
  <xsl:template match="rpIndName[../rpOrgName = 'Esri Learning Center']" priority="1" >
  </xsl:template>
  
  <!-- edit the address for any contact with the organization name Esri Learning Center -->
  <xsl:variable name="newAddress" >
    <cntAddress>
      <delPoint>380 New York St.</delPoint>
      <city>Redlands</city>
      <adminArea>CA</adminArea>
      <postCode>92373-8100</postCode>
      <country>US</country>
      <eMailAdd>LearnGIS@esri.com</eMailAdd>
    </cntAddress>
  </xsl:variable> 
  <xsl:template match="cntAddress[../../rpOrgName = 'Esri Learning Center']" priority="1" >
    <xsl:copy-of select="$newAddress" />
  </xsl:template>

  <!-- edit all contacts with the organization name Esri Learning Center to have a new phone number -->
  <xsl:variable name="newPhone">888-377-4575 x.1-3204</xsl:variable> 
  <xsl:template match="voiceNum[../../../rpOrgName = 'Esri Learning Center']" priority="1" >
    <voiceNum><xsl:value-of select="$newPhone" /></voiceNum>
  </xsl:template>
  
  <!-- add hours of availability for the organization name Esri Learning Center -->
  <xsl:template match="rpCntInfo[../rpOrgName = 'Esri Learning Center']" priority="1" >
    <xsl:copy>
      <xsl:apply-templates select="node() | @*" />
      <cntOnlineRes>
        <linkage>http://www.esri.com/training</linkage>
      </cntOnlineRes>
      <cntHours>8:00am to 5:00pm Pacific Time</cntHours>
    </xsl:copy>
  </xsl:template>
  
</xsl:stylesheet>

この XSLT を使用し、上に例として示したメタデータを [XSLT 変換] ツールを使用して編集すると、次のような出力 XML ファイルが出力として作成されます。[メタデータ インポータ] ツールを使用して、元の ArcGIS アイテムとともにこれらの変更を保存します。

上記の XSLT スタイルシートで作成した更新済みメタデータの抜粋です。

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <mdContact>
    <rpOrgName>Esri Learning Center</rpOrgName>
    <rpCntInfo>
      <cntAddress>
        <delPoint>380 New York St.</delPoint>
        <city>Redlands</city>
        <adminArea>CA</adminArea>
        <postCode>92373-8100</postCode>
        <country>US</country>
        <eMailAdd>LearnGIS@esri.com</eMailAdd>
      </cntAddress>
      <cntPhone>
        <voiceNum>888-377-4575 x.1-3204</voiceNum>
        <faxNum>909-793-4801</faxNum>
      </cntPhone>
      <cntOnlineRes>
        <linkage>http://www.esri.com/training</linkage>
      </cntOnlineRes>
      <cntHours>8:00am to 5:00pm Pacific Time</cntHours>
    </rpCntInfo>
    <role>
      <RoleCd value="010"/>
    </role>
  </mdContact>
  ...
</metadata>

ArcGIS Desktop では、<ArcGIS Desktop Install インストール フォルダ>\Metadata\Stylesheets\gpTools フォルダに、[変換] ツールボックスでメタデータ ジオプロセシング モデルをサポートするいくつかの XSLT スタイルシートが提供されています。これらを例として使用してください。

独自のスタイルシートを作成するときは、使用する XML 形式を理解しておくと役立ちます。ArcGIS メタデータ XML 形式について説明した XML DTD が <ArcGIS Desktop インストール フォルダ>\Metadata\Translator\Rules フォルダに入っています。

関連項目


7/10/2012