/** * XPath composition utilities using the <code>XmpPathFactory</code>. * @throws XmpException Forwards exceptions */ private static void CoverPathCreation() { writeMajorLabel("XPath composition utilities"); var meta = XmpMetaFactory.Create(); meta.AppendArrayItem(TestData.NS1, "ArrayProp", new PropertyOptions { IsArray = true }, "Item 1", null); string path = XmpPathFactory.ComposeArrayItemPath("ArrayProp", 2); log.WriteLine("composeArrayItemPath ArrayProp[2] = " + path); meta.SetProperty(TestData.NS1, path, "new ns1:ArrayProp[2] value"); path = "StructProperty"; path += XmpPathFactory.ComposeStructFieldPath(TestData.NS2, "Field3"); log.WriteLine("composeStructFieldPath StructProperty/ns2:Field3 = " + path); meta.SetProperty(TestData.NS1, path, "new ns1:StructProp/ns2:Field3 value"); path = "QualProp"; path += XmpPathFactory.ComposeQualifierPath(TestData.NS2, "Qual"); log.WriteLine("composeStructFieldPath QualProp/?ns2:Qual = " + path); meta.SetProperty(TestData.NS1, path, "new ns1:QualProp/?ns2:Qual value"); meta.SetLocalizedText(TestData.NS1, "AltTextProp", null, "en-US", "initival value"); path = "AltTextProp"; path += XmpPathFactory.ComposeQualifierPath(XmpConstants.NsXml, "lang"); log.WriteLine("composeQualifierPath ns1:AltTextProp/?xml:lang = " + path); meta.SetProperty(TestData.NS1, path, "new ns1:AltTextProp/?xml:lang value"); printXmpMeta(meta, "Modified simple RDF"); }
/// <exception cref="XmpException"/> public void SetStructField(string schemaNs, string structName, string fieldNs, string fieldName, string fieldValue, PropertyOptions options) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertStructName(structName); var fieldPath = structName + XmpPathFactory.ComposeStructFieldPath(fieldNs, fieldName); SetProperty(schemaNs, fieldPath, fieldValue, options); }
/// <exception cref="XmpException"/> public IXmpProperty GetArrayItem(string schemaNs, string arrayName, int itemIndex) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertArrayName(arrayName); var itemPath = XmpPathFactory.ComposeArrayItemPath(arrayName, itemIndex); return(GetProperty(schemaNs, itemPath)); }
/// <exception cref="XmpException"/> public IXmpProperty GetStructField(string schemaNs, string structName, string fieldNs, string fieldName) { // fieldNS and fieldName are checked inside composeStructFieldPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertStructName(structName); var fieldPath = structName + XmpPathFactory.ComposeStructFieldPath(fieldNs, fieldName); return(GetProperty(schemaNs, fieldPath)); }
/// <exception cref="XmpException"/> public IXmpProperty GetQualifier(string schemaNs, string propName, string qualNs, string qualName) { // qualNS and qualName are checked inside composeQualfierPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); var qualPath = propName + XmpPathFactory.ComposeQualifierPath(qualNs, qualName); return(GetProperty(schemaNs, qualPath)); }
/// <exception cref="XmpException"/> public void SetQualifier(string schemaNs, string propName, string qualNs, string qualName, string qualValue, PropertyOptions options) { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); if (!DoesPropertyExist(schemaNs, propName)) { throw new XmpException("Specified property does not exist!", XmpErrorCode.BadXPath); } var qualPath = propName + XmpPathFactory.ComposeQualifierPath(qualNs, qualName); SetProperty(schemaNs, qualPath, qualValue, options); }
/// <seealso cref= XMPMeta#doesArrayItemExist(String, String, int) </seealso> public virtual bool DoesArrayItemExist(string schemaNs, string arrayName, int itemIndex) { try { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertArrayName(arrayName); string path = XmpPathFactory.ComposeArrayItemPath(arrayName, itemIndex); return(DoesPropertyExist(schemaNs, path)); } catch (XmpException) { return(false); } }
/// <seealso cref= XMPMeta#deleteArrayItem(String, String, int) </seealso> public virtual void DeleteArrayItem(string schemaNs, string arrayName, int itemIndex) { try { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertArrayName(arrayName); string itemPath = XmpPathFactory.ComposeArrayItemPath(arrayName, itemIndex); DeleteProperty(schemaNs, itemPath); } catch (XmpException) { // EMPTY, exceptions are ignored within delete } }
public void DeleteArrayItem(string schemaNs, string arrayName, int itemIndex) { try { ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertArrayName(arrayName); var itemPath = XmpPathFactory.ComposeArrayItemPath(arrayName, itemIndex); DeleteProperty(schemaNs, itemPath); } catch (XmpException) { } }
/// <seealso cref= XMPMeta#doesQualifierExist(String, String, String, String) </seealso> public virtual bool DoesQualifierExist(string schemaNs, string propName, string qualNs, string qualName) { try { // qualNs and qualName are checked inside composeQualifierPath() ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); string path = XmpPathFactory.ComposeQualifierPath(qualNs, qualName); return(DoesPropertyExist(schemaNs, propName + path)); } catch (XmpException) { return(false); } }
/// <seealso cref= XMPMeta#doesStructFieldExist(String, String, String, String) </seealso> public virtual bool DoesStructFieldExist(string schemaNs, string structName, string fieldNs, string fieldName) { try { // fieldNs and fieldName are checked inside composeStructFieldPath() ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertStructName(structName); string path = XmpPathFactory.ComposeStructFieldPath(fieldNs, fieldName); return(DoesPropertyExist(schemaNs, structName + path)); } catch (XmpException) { return(false); } }
/// <seealso cref= XMPMeta#deleteStructField(String, String, String, String) </seealso> public virtual void DeleteStructField(string schemaNs, string structName, string fieldNs, string fieldName) { try { // fieldNs and fieldName are checked inside composeStructFieldPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertStructName(structName); string fieldPath = structName + XmpPathFactory.ComposeStructFieldPath(fieldNs, fieldName); DeleteProperty(schemaNs, fieldPath); } catch (XmpException) { // EMPTY, exceptions within delete are ignored } }
/// <seealso cref= XMPMeta#deleteQualifier(String, String, String, String) </seealso> public virtual void DeleteQualifier(string schemaNs, string propName, string qualNs, string qualName) { try { // Note: qualNs and qualName are checked inside composeQualfierPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); string qualPath = propName + XmpPathFactory.ComposeQualifierPath(qualNs, qualName); DeleteProperty(schemaNs, qualPath); } catch (XmpException) { // EMPTY, exceptions within delete are ignored } }
public void DeleteStructField(string schemaNs, string structName, string fieldNs, string fieldName) { try { // fieldNS and fieldName are checked inside composeStructFieldPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertStructName(structName); var fieldPath = structName + XmpPathFactory.ComposeStructFieldPath(fieldNs, fieldName); DeleteProperty(schemaNs, fieldPath); } catch (XmpException) { } }
public void DeleteQualifier(string schemaNs, string propName, string qualNs, string qualName) { try { // Note: qualNS and qualName are checked inside composeQualfierPath ParameterAsserts.AssertSchemaNs(schemaNs); ParameterAsserts.AssertPropName(propName); var qualPath = propName + XmpPathFactory.ComposeQualifierPath(qualNs, qualName); DeleteProperty(schemaNs, qualPath); } catch (XmpException) { } }