Adds a new resource to a resource repository, or updates an existing resource.
.NET Syntax
Java Syntax
PHP Syntax
Example (PHP)
To add a resource: 1) Prepare the resource's content XML file using the schema appropriate to the type. a) If the resource references other resources, use the <uri> elements to specify their paths in the repository. For example a map file, called World.MapDefinition, might look like this: <?xml version="1.0" encoding="UTF-8"?> <MapDefinition version="1.0.0"> <Name>World</Name> <Layers> <Layer> <Name>Cities</Name> <ResourceId>Library://World/Layers/Cities.Layer</ResourceId> </Layer> <Layer> <Name>Countries</Name> <ResourceId>Library://World/Layers/Countries.Layer</ResourceId> </Layer> </Layers> </MapDefinition>
b) If the resource uses resource data, specify the path with <?xml version="1.0" encoding="UTF-8"?> <DrawingSource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DrawingSource-1.0.0.xsd"> <SourceName>\%MG_DATA_FILE_PATH\%test.dwf</SourceName> <Password/> <CoordinateSpace>LL84</CoordinateSpace> </DrawingSource>
For more information on %MG_DATA_FILE_PATH% and other substitution tags, see MgResourceTag. <?xml version="1.0" encoding="UTF-8"?> <ResourceDocumentHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ResourceDocumentHeader-1.0.0.xsd"> <Security> <Inherited>true</Inherited> </Security> <Dependency> <ResourceId>Library://World/Layers/Cities.LoadProcedure</ResourceId> </Dependency> </ResourceDocumentHeader> 3) Add the resource to the repository using those content and header files: $resourceID= new MgResourceIdentifier("Library://Geography/World.MapDefinition"); $content = "C:\Data\Maps\World.MapDefinition"; $content_byteSource = new MgByteSource($content); $content_byteSource->setMimeType("text/xml"); $content_byteReader = $content_byteSource->GetReader(); $header = "C:\Data\Maps\Resource\DocumentHeader.xml"; $header_byteSource = new MgByteSource($header); $header_byteSource->setMimeType("text/xml"); $header_byteReader = $header_byteSource->GetReader(); // Assuming $resourceService is already initialized. $resourceService->SetResource($resourceID, $content_byteReader, $header_byteReader); 4) If the resource references other resources, you must also add them. In the World.MapDefinition example above, you would add the XML file for Cities.Layer to the repository at the location Library://World/Layers/Cities.Layer . Similarly, you would add Countries.Layer to Library://World/Layers/Countries.Layer . 5) Set any necessary resource data. See SetResourceData.
|