Main Content

setRDF

Set RDF content for local OSLC resource object

Since R2021a

    Description

    example

    setRDF(resource,rdfContent) sets the XML/RDF data to the content specified by rdfContent for the resource specified by resource. Use the commit function to apply the change to the service provider. For more information, see RDF classes and properties in OSLC on the Open Services for Lifecycle Collaboration (OSLC) website.

    Examples

    collapse all

    This example shows how to get and set the RDF content of an OSLC requirement resource with a configured OSLC client.

    After you have created and configured the OSLC client myClient as described in Create and Configure an OSLC Client for the Requirements Management Domain, create a query capability for the requirement resource type.

    myQueryCapability = getQueryService(myClient);

    Submit a query request to the service provider for the available requirement resources.

    reqs = queryRequirements(myQueryCapability)
    reqs = 
    
      1×30 Requirement array with properties:
    
        ResourceUrl
        Dirty
        IsFetched
        Title
        Identifier

    Fetch the full resource properties for a single requirement resource. Inspect the title of the requirement.

    myReq = reqs(1);
    status = fetch(myReq,myClient)
    status = 
    
      StatusCode enumeration
    
        OK
    title = myReq.Title
    title =
    
        'My New Requirement'
    

    Get the locally stored RDF content of the requirement resource.

    rdfContent = getRDF(myReq)
    rdfContent =
    
        '<?xml version="1.0" encoding="UTF-8" standalone="no" ?><rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:oslc="http://open-services.net/ns/core#"
    xmlns:oslc_rm="http://open-services.net/ns/rm#">
              <oslc_rm:Requirement>
             <dcterms:title>My New
    Requirement</dcterms:title><oslc:instanceShape
    rdf:resource="https://example.com/shapes/oslc-requirement-version1"/>
    </oslc_rm:Requirement>
         </rdf:RDF>'

    Copy and paste the rdfContent text into a new variable newRDF. Edit the text contents for the dcterms:title property to My New Requirement (Edited).

    newRDF = ['<?xml version="1.0" encoding="UTF-8" ' ...
    'standalone="no" ?><rdf:RDF ' ...
    'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ' ...
    'xmlns:dcterms="http://purl.org/dc/terms/" ' ...
    'xmlns:oslc="http://open-services.net/ns/core#" ' ...
    'xmlns:oslc_rm="http://open-services.net/ns/rm#">' ...
    '<oslc_rm:Requirement><dcterms:title>' ...
    'My New Requirement (Edited)</dcterms:title>' ...
    '<oslc:instanceShape rdf:resource=' ...
    '"https://example.com/shapes/oslc-requirement-version1"/>' ...
    '</oslc_rm:Requirement></rdf:RDF>']

    Set the RDF content of the requirement to the variable newRDF. Inspect the requirement title.

    setRDF(myReq,newRDF);
    title = myReq.Title
    title =
    
        'My New Requirement (Edited)'
    

    Commit the changes to the service provider.

    status = commit(newReq,myClient)
    status = 
    
      StatusCode enumeration
    
        OK

    Input Arguments

    collapse all

    RDF data for OSLC resource, specified as a character vector.

    Version History

    Introduced in R2021a