From 843c7af4ffc97c58848737d9d5db3c37823993b9 Mon Sep 17 00:00:00 2001 From: vdelachaux Date: Mon, 23 Sep 2024 13:43:08 +0200 Subject: [PATCH] #DECLARE & var - part 2 --- Project/Sources/Methods/COMPILER_xml.4dm | 41 ----- Project/Sources/Methods/xmlColoredSyntax.4dm | 150 ++++++++---------- Project/Sources/Methods/xml_COPY_ELEMENT.4dm | 127 +++++++-------- .../Sources/Methods/xml_Duplicate_element.4dm | 67 +++----- .../Sources/Methods/xml_Escape_characters.4dm | 80 +++------- .../Sources/Methods/xml_findInfoPListKey.4dm | 79 +++------ .../Sources/Methods/xml_getInfoPListKey.4dm | 107 ++++--------- .../Sources/Methods/xml_referenceValid.4dm | 27 +--- .../Sources/Methods/xml_remove_attribute.4dm | 68 +++----- Project/Sources/folders.json | 1 - 10 files changed, 248 insertions(+), 499 deletions(-) delete mode 100644 Project/Sources/Methods/COMPILER_xml.4dm diff --git a/Project/Sources/Methods/COMPILER_xml.4dm b/Project/Sources/Methods/COMPILER_xml.4dm deleted file mode 100644 index 48014d4..0000000 --- a/Project/Sources/Methods/COMPILER_xml.4dm +++ /dev/null @@ -1,41 +0,0 @@ -//%attributes = {"invisible":true} -If (False:C215) - - // ---------------------------------------------------- - C_TEXT:C284(xml_COPY_ELEMENT ;$1) - C_TEXT:C284(xml_COPY_ELEMENT ;$2) - - // ---------------------------------------------------- - C_TEXT:C284(xml_Duplicate_element ;$0) - C_TEXT:C284(xml_Duplicate_element ;$1) - C_TEXT:C284(xml_Duplicate_element ;$2) - - // ---------------------------------------------------- - C_TEXT:C284(xml_Escape_characters ;$0) - C_TEXT:C284(xml_Escape_characters ;$1) - - // ---------------------------------------------------- - C_BOOLEAN:C305(xml_referenceValid ;$0) - C_TEXT:C284(xml_referenceValid ;$1) - - // ---------------------------------------------------- - C_TEXT:C284(xml_remove_attribute ;$1) - C_TEXT:C284(xml_remove_attribute ;$2) - - // ---------------------------------------------------- - C_TEXT:C284(xmlColoredSyntax ;$0) - C_TEXT:C284(xmlColoredSyntax ;$1) - - // ---------------------------------------------------- - C_TEXT:C284(xml_findInfoPListKey ;$0) - C_TEXT:C284(xml_findInfoPListKey ;$1) - C_TEXT:C284(xml_findInfoPListKey ;$2) - - // ---------------------------------------------------- - C_BOOLEAN:C305(xml_getInfoPListKey ;$0) - C_TEXT:C284(xml_getInfoPListKey ;$1) - C_TEXT:C284(xml_getInfoPListKey ;$2) - C_POINTER:C301(xml_getInfoPListKey ;$3) - - // ---------------------------------------------------- -End if \ No newline at end of file diff --git a/Project/Sources/Methods/xmlColoredSyntax.4dm b/Project/Sources/Methods/xmlColoredSyntax.4dm index 175ee49..8e37d63 100644 --- a/Project/Sources/Methods/xmlColoredSyntax.4dm +++ b/Project/Sources/Methods/xmlColoredSyntax.4dm @@ -7,122 +7,96 @@ // Description: // Return colored XML to display in a Multi-style text object // ---------------------------------------------------- -// Declarations -C_TEXT:C284($0) -C_TEXT:C284($1) +#DECLARE($xml : Text) : Text -C_LONGINT:C283($Lon_error; $Lon_parameters) -C_TEXT:C284($Txt_attributeFontWeight; $Txt_attributeNameColor; $Txt_attributeValueColor; $Txt_commentColor; $Txt_commentFontWeight; $Txt_defaultColor) -C_TEXT:C284($Txt_defaultFontWeight; $Txt_doctypeColor; $Txt_doctypeFontWeight; $Txt_elementColor; $Txt_elementFontWeight; $Txt_entityColor) -C_TEXT:C284($Txt_entityFontWeight; $Txt_pattern; $Txt_processingColor; $Txt_processingFontWeight; $Txt_styleAttribute; $Txt_styleComment) -C_TEXT:C284($Txt_styleDoctype; $Txt_styleElement; $Txt_styleEntity; $Txt_styleProcessing; $Txt_xml) +var $Txt_attributeFontWeight; $Txt_attributeNameColor; $Txt_attributeValueColor; $Txt_commentColor; $Txt_commentFontWeight; $Txt_defaultColor : Text +var $Txt_defaultFontWeight; $Txt_doctypeColor; $Txt_doctypeFontWeight; $Txt_elementColor; $Txt_elementFontWeight; $Txt_entityColor : Text +var $Txt_entityFontWeight; $Txt_pattern; $Txt_processingColor; $Txt_processingFontWeight; $Txt_styleAttribute; $Txt_styleComment : Text +var $Txt_styleDoctype; $Txt_styleElement; $Txt_styleEntity; $Txt_styleProcessing : Text +var $Lon_error : Integer -If (False:C215) - C_TEXT:C284(xmlColoredSyntax; $0) - C_TEXT:C284(xmlColoredSyntax; $1) -End if +$Txt_defaultColor:=Get Application color scheme:C1763="dark" ? "white" : "black" +$Txt_defaultFontWeight:="normal" -// ---------------------------------------------------- -// Initialisations -$Lon_parameters:=Count parameters:C259 - -If (Asserted:C1132($Lon_parameters>=1; Get localized string:C991("error_missingParameter"))) - - $Txt_xml:=$1 - - $Txt_defaultColor:=Get Application color scheme:C1763="dark" ? "white" : "black" - $Txt_defaultFontWeight:="normal" - - $Txt_elementColor:="#2a2aa7" - $Txt_elementFontWeight:="normal" - - $Txt_attributeFontWeight:="normal" - $Txt_attributeNameColor:="#f58953" - $Txt_attributeValueColor:="#9d3d0a" - - $Txt_commentColor:="green" - $Txt_commentFontWeight:="normal" - - $Txt_processingColor:="#8526C2" - $Txt_processingFontWeight:="normal" - - $Txt_doctypeColor:="blue" - $Txt_doctypeFontWeight:="normal" - - $Txt_entityColor:="#94961C" - $Txt_entityFontWeight:="normal" - - $Txt_styleElement:="\\1" - - $Txt_styleAttribute:="\\1=\"\\2\"" - - $Txt_styleComment:="\\1" - - $Txt_styleProcessing:="\\1" - - $Txt_styleDoctype:="\\1" - - $Txt_styleEntity:="\\1" - -Else - - ABORT:C156 - -End if +$Txt_elementColor:="#2a2aa7" +$Txt_elementFontWeight:="normal" -// ---------------------------------------------------- +$Txt_attributeFontWeight:="normal" +$Txt_attributeNameColor:="#f58953" +$Txt_attributeValueColor:="#9d3d0a" + +$Txt_commentColor:="green" +$Txt_commentFontWeight:="normal" + +$Txt_processingColor:="#8526C2" +$Txt_processingFontWeight:="normal" + +$Txt_doctypeColor:="blue" +$Txt_doctypeFontWeight:="normal" + +$Txt_entityColor:="#94961C" +$Txt_entityFontWeight:="normal" + +$Txt_styleElement:="\\1" + +$Txt_styleAttribute:="\\1=\"\\2\"" + +$Txt_styleComment:="\\1" + +$Txt_styleProcessing:="\\1" + +$Txt_styleDoctype:="\\1" + +$Txt_styleEntity:="\\1" // Replace < and > caracteres -$Txt_xml:=Replace string:C233($Txt_xml; "<"; "_§§") -$Txt_xml:=Replace string:C233($Txt_xml; ">"; "_¿¿") +$xml:=Replace string:C233($xml; "<"; "_§§") +$xml:=Replace string:C233($xml; ">"; "_¿¿") // #ACI0098253 -$Txt_xml:=Replace string:C233($Txt_xml; "&"; "&") +$xml:=Replace string:C233($xml; "&"; "&") // Processing instruction $Txt_pattern:="(_\\?[^_¿¿]*\\?_¿¿)" -$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleProcessing; ->$Txt_xml) +$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleProcessing; ->$xml) // Attributes $Txt_pattern:="(\\s+[^= ]*)=\"([^\"]*)\"(?!.*\\?_¿¿)" -$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleAttribute; ->$Txt_xml) +$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleAttribute; ->$xml) // Elements $Txt_pattern:="(_\\[^?_¿¿]*_¿¿)" -$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleElement; ->$Txt_xml) +$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleElement; ->$xml) // Comments $Txt_pattern:="(_\\!--.*?--_¿¿)" -$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleComment; ->$Txt_xml) +$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleComment; ->$xml) // Default -$Txt_xml:=""+$Txt_xml+"" +$xml:=""+$xml+"" // Doctype $Txt_pattern:="(_\\\\![^-][^_¿¿]*_¿¿)" -$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleDoctype; ->$Txt_xml) +$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleDoctype; ->$xml) // Entities $Txt_pattern:="(&[^;]*;)" -$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleEntity; ->$Txt_xml) +$Lon_error:=Rgx_SubstituteText($Txt_pattern; $Txt_styleEntity; ->$xml) // Restore < and > caracteres -$Txt_xml:=Replace string:C233($Txt_xml; "_§§"; "<") -$Txt_xml:=Replace string:C233($Txt_xml; "_¿¿"; ">") - -// ---------------------------------------------------- -// End +$xml:=Replace string:C233($xml; "_§§"; "<") +$xml:=Replace string:C233($xml; "_¿¿"; ">") -$0:=$Txt_xml \ No newline at end of file +return $xml \ No newline at end of file diff --git a/Project/Sources/Methods/xml_COPY_ELEMENT.4dm b/Project/Sources/Methods/xml_COPY_ELEMENT.4dm index ad631f0..8c5dd20 100644 --- a/Project/Sources/Methods/xml_COPY_ELEMENT.4dm +++ b/Project/Sources/Methods/xml_COPY_ELEMENT.4dm @@ -1,83 +1,78 @@ //%attributes = {"invisible":true} - // ---------------------------------------------------- - // Method : xml_COPY_ELEMENT - // Created 08/09/08 by Vincent de Lachaux - // ---------------------------------------------------- - // Description - // - // ---------------------------------------------------- -C_TEXT:C284($1) -C_TEXT:C284($2) +// ---------------------------------------------------- +// Method : xml_COPY_ELEMENT +// Created 08/09/08 by Vincent de Lachaux +// ---------------------------------------------------- +#DECLARE($src : Text; $tgt : Text) -C_BOOLEAN:C305($Boo_OK;$Boo_stop) -C_LONGINT:C283($Lon_i) -C_TEXT:C284($Txt_Name;$Txt_nameBuffer;$Txt_Ref;$Txt_sourceRef;$Txt_target;$Txt_targetRef) -C_TEXT:C284($Txt_Value;$Txt_valueBuffer) +var $name; $node; $ref; $srcName; $srcValue; $value : Text +var $success : Boolean +var $i : Integer -If (False:C215) - C_TEXT:C284(xml_COPY_ELEMENT ;$1) - C_TEXT:C284(xml_COPY_ELEMENT ;$2) -End if - -$Txt_sourceRef:=$1 -$Txt_targetRef:=$2 - -If (Asserted:C1132(xml_referenceValid ($Txt_sourceRef) & xml_referenceValid ($Txt_targetRef);Get localized string:C991("error_badReference"))) +If (Asserted:C1132(xml_referenceValid($src) & xml_referenceValid($tgt); Localized string:C991("error_badReference"))) - $Txt_Ref:=DOM Get first child XML element:C723($Txt_sourceRef;$Txt_Name;$Txt_Value) + $ref:=DOM Get first child XML element:C723($src; $srcName; $srcValue) - If (OK=1) + If (OK=0) + + return + + End if + + Repeat + + $node:=DOM Create XML element:C865($tgt; $srcName) - Repeat + If (Not:C34(Bool:C1537(OK))) - $Txt_target:=DOM Create XML element:C865($Txt_targetRef;$Txt_Name) - $Boo_OK:=(OK=1) + break - If ($Boo_OK) - - If (Length:C16($Txt_Value)>0) - - DOM SET XML ELEMENT VALUE:C868($Txt_target;$Txt_Value) - $Boo_OK:=(OK=1) - - End if - - If ($Boo_OK) - - For ($Lon_i;1;DOM Count XML attributes:C727($Txt_Ref);1) - - DOM GET XML ATTRIBUTE BY INDEX:C729($Txt_Ref;$Lon_i;$Txt_nameBuffer;$Txt_valueBuffer) - $Boo_OK:=(OK=1) - - If ($Boo_OK) - - DOM SET XML ATTRIBUTE:C866($Txt_target;\ - $Txt_nameBuffer;$Txt_valueBuffer) - - Else - - $Lon_i:=MAXLONG:K35:2-1 - - End if - End for - End if - End if + End if + + $success:=Bool:C1537(OK) + + If (Length:C16($srcValue)>0) + + DOM SET XML ELEMENT VALUE:C868($node; $srcValue) - If ($Boo_OK) + If (Not:C34(Bool:C1537(OK))) - xml_COPY_ELEMENT ($Txt_Ref;$Txt_target) + break End if + End if + + For ($i; 1; DOM Count XML attributes:C727($ref); 1) - If ($Boo_OK) - - $Txt_Ref:=DOM Get next sibling XML element:C724($Txt_Ref;$Txt_Name;$Txt_Value) + DOM GET XML ATTRIBUTE BY INDEX:C729($ref; $i; $name; $value) + + If (Not:C34(Bool:C1537(OK))) - $Boo_stop:=(OK=0) - OK:=1 + break End if - Until (Not:C34($Boo_OK))\ - | ($Boo_stop) - End if + + DOM SET XML ATTRIBUTE:C866($node; \ + $name; $value) + + End for + + If (Not:C34(Bool:C1537(OK))) + + break + + End if + + xml_COPY_ELEMENT($ref; $node) + + $ref:=DOM Get next sibling XML element:C724($ref; $srcName; $srcValue) + + If (Not:C34(Bool:C1537(OK))) + + OK:=1 + + break + + End if + Until (False:C215) End if \ No newline at end of file diff --git a/Project/Sources/Methods/xml_Duplicate_element.4dm b/Project/Sources/Methods/xml_Duplicate_element.4dm index 99872c7..4163b69 100644 --- a/Project/Sources/Methods/xml_Duplicate_element.4dm +++ b/Project/Sources/Methods/xml_Duplicate_element.4dm @@ -1,59 +1,44 @@ //%attributes = {"invisible":true} - // ---------------------------------------------------- - // Method : xml_DUPLICATE_ELEMENT - // Created 05/09/08 by Vincent de Lachaux - // ---------------------------------------------------- - // Description - // - // ---------------------------------------------------- -C_TEXT:C284($0) -C_TEXT:C284($1) -C_TEXT:C284($2) +// ---------------------------------------------------- +// Method : xml_DUPLICATE_ELEMENT +// Created 05/09/08 by Vincent de Lachaux +// ---------------------------------------------------- +#DECLARE($src : Text; $tgt : Text) : Text -C_BLOB:C604($Blb_xml) -C_LONGINT:C283($Lon_i) -C_TEXT:C284($Txt_Name;$Txt_nameBuffer;$Txt_sourceRef;$Txt_sourceRoot;$Txt_targetRef;$Txt_targetRoot) -C_TEXT:C284($Txt_valueBuffer) +var $srcRoot; $tgtName; $tgtRoot; $tgtValue : Text +var $i : Integer +var $blb : Blob -If (False:C215) - C_TEXT:C284(xml_Duplicate_element ;$0) - C_TEXT:C284(xml_Duplicate_element ;$1) - C_TEXT:C284(xml_Duplicate_element ;$2) -End if - -$Txt_sourceRef:=$1 -$Txt_targetRef:=$2 - -If (Asserted:C1132(xml_referenceValid ($Txt_sourceRef) & xml_referenceValid ($Txt_targetRef);Get localized string:C991("error_badReference"))) +If (Asserted:C1132(xml_referenceValid($src) & xml_referenceValid($tgt); Localized string:C991("error_badReference"))) - DOM EXPORT TO VAR:C863($Txt_sourceRef;$Blb_xml) + DOM EXPORT TO VAR:C863($src; $blb) - If (OK=1) + If (Bool:C1537(OK)) - $Txt_sourceRoot:=DOM Parse XML variable:C720($Blb_xml;False:C215) + $srcRoot:=DOM Parse XML variable:C720($blb; False:C215) - If (OK=1) + If (Bool:C1537(OK)) - DOM GET XML ELEMENT NAME:C730($Txt_sourceRoot;$Txt_Name) + DOM GET XML ELEMENT NAME:C730($srcRoot; $tgtName) - If (OK=1) + If (Bool:C1537(OK)) - $Txt_targetRoot:=DOM Create XML element:C865($Txt_targetRef;$Txt_Name) + $tgtRoot:=DOM Create XML element:C865($tgt; $tgtName) - If (OK=1) + If (Bool:C1537(OK)) - For ($Lon_i;1;DOM Count XML attributes:C727($Txt_sourceRoot);1) + For ($i; 1; DOM Count XML attributes:C727($srcRoot); 1) - DOM GET XML ATTRIBUTE BY INDEX:C729($Txt_sourceRoot;$Lon_i;$Txt_nameBuffer;$Txt_valueBuffer) + DOM GET XML ATTRIBUTE BY INDEX:C729($srcRoot; $i; $tgtName; $tgtValue) - If (OK=1) + If (Bool:C1537(OK)) - DOM SET XML ATTRIBUTE:C866($Txt_targetRoot;\ - $Txt_nameBuffer;$Txt_valueBuffer) + DOM SET XML ATTRIBUTE:C866($tgtRoot; \ + $tgtName; $tgtValue) Else - $Lon_i:=MAXLONG:K35:2-1 + break End if End for @@ -62,11 +47,11 @@ If (Asserted:C1132(xml_referenceValid ($Txt_sourceRef) & xml_referenceValid ($Tx End if End if - If (OK=1) + If (Bool:C1537(OK)) - $0:=$Txt_targetRoot + xml_COPY_ELEMENT($srcRoot; $tgtRoot) - xml_COPY_ELEMENT ($Txt_sourceRoot;$Txt_targetRoot) + return $tgtRoot End if End if \ No newline at end of file diff --git a/Project/Sources/Methods/xml_Escape_characters.4dm b/Project/Sources/Methods/xml_Escape_characters.4dm index 0f1b704..db1ade0 100644 --- a/Project/Sources/Methods/xml_Escape_characters.4dm +++ b/Project/Sources/Methods/xml_Escape_characters.4dm @@ -1,62 +1,26 @@ //%attributes = {"invisible":true} - // ---------------------------------------------------- - // Project method : xml_Escape_characters - // Database: 4D SVG - // ID[65529C66F0BD4ADB99224E368FD6C504] - // Created #25-1-2017 by Vincent de Lachaux - // ---------------------------------------------------- - // Description: - // Encode special characters - // ampersand (&) is escaped to & - // double quotes (") are escaped to " - // single quotes (') are escaped to ' - // less than (<) is escaped to < - // greater than (>) is escaped to > - // ---------------------------------------------------- - // Declarations -C_TEXT:C284($0) -C_TEXT:C284($1) +// ---------------------------------------------------- +// Project method : xml_Escape_characters +// Database: 4D SVG +// ID[65529C66F0BD4ADB99224E368FD6C504] +// Created #25-1-2017 by Vincent de Lachaux +// ---------------------------------------------------- +// Description: +// Encode special characters +// Ampersand (&) is escaped to & +// Double quotes (") are escaped to " +// Single quotes (') are escaped to ' +// Less than (<) is escaped to < +// Greater than (>) is escaped to > +// ---------------------------------------------------- +#DECLARE($in : Text) : Text -C_LONGINT:C283($Lon_parameters) -C_TEXT:C284($Txt_escaped;$Txt_text) +var $out : Text:=$in -If (False:C215) - C_TEXT:C284(xml_Escape_characters ;$0) - C_TEXT:C284(xml_Escape_characters ;$1) -End if +$out:=Replace string:C233($out; "&"; "&") +$out:=Replace string:C233($out; "\""; """) +$out:=Replace string:C233($out; "'"; "'") +$out:=Replace string:C233($out; "<"; "<") +$out:=Replace string:C233($out; ">"; ">") - // ---------------------------------------------------- - // Initialisations -$Lon_parameters:=Count parameters:C259 - -If (Asserted:C1132($Lon_parameters>=1;"Missing parameter")) - - //Required parameters - $Txt_text:=$1 - - //Optional parameters - If ($Lon_parameters>=2) - - // - - End if - -Else - - ABORT:C156 - -End if - - // ---------------------------------------------------- -$Txt_escaped:=Replace string:C233($Txt_text;"&";"&") -$Txt_escaped:=Replace string:C233($Txt_escaped;"\"";""") -$Txt_escaped:=Replace string:C233($Txt_escaped;"'";"'") -$Txt_escaped:=Replace string:C233($Txt_escaped;"<";"<") -$Txt_escaped:=Replace string:C233($Txt_escaped;">";">") - - // ---------------------------------------------------- - // Return -$0:=$Txt_escaped - - // ---------------------------------------------------- - // End \ No newline at end of file +return $out \ No newline at end of file diff --git a/Project/Sources/Methods/xml_findInfoPListKey.4dm b/Project/Sources/Methods/xml_findInfoPListKey.4dm index 03b3482..0dd015b 100644 --- a/Project/Sources/Methods/xml_findInfoPListKey.4dm +++ b/Project/Sources/Methods/xml_findInfoPListKey.4dm @@ -1,70 +1,29 @@ //%attributes = {"invisible":true} - // ---------------------------------------------------- - // Project method : xml_findInfoPListKey - // Database: 4D unitTest - // ID[B7EC674F8A734019BBD81F2640FFAC33] - // Created #14-9-2016 by Vincent de Lachaux - // ---------------------------------------------------- - // Description: - // Finds an Info.PList element reference using a supplied XML root reference - // ---------------------------------------------------- - // Declarations -C_TEXT:C284($0) -C_TEXT:C284($1) -C_TEXT:C284($2) +// ---------------------------------------------------- +// Project method : xml_findInfoPListKey +// Database: 4D unitTest +// ID[B7EC674F8A734019BBD81F2640FFAC33] +// Created #14-9-2016 by Vincent de Lachaux +// ---------------------------------------------------- +// Description: +// Finds an Info.PList element reference using a supplied XML root reference +// ---------------------------------------------------- +#DECLARE($root : Text; $key : Text) : Text -C_LONGINT:C283($Lon_i;$Lon_parameters) -C_TEXT:C284($Dom_key;$Dom_root;$Txt_key;$Txt_value) +var $value : Text +var $i : Integer -ARRAY TEXT:C222($tDom_elements;0) +ARRAY TEXT:C222($_nodes; 0) -If (False:C215) - C_TEXT:C284(xml_findInfoPListKey ;$0) - C_TEXT:C284(xml_findInfoPListKey ;$1) - C_TEXT:C284(xml_findInfoPListKey ;$2) -End if +$_nodes{0}:=DOM Find XML element:C864($root; "/plist/dict/key"; $_nodes) - // ---------------------------------------------------- - // Initialisations -$Lon_parameters:=Count parameters:C259 - -If (Asserted:C1132($Lon_parameters>=2;"Missing parameter")) +For ($i; 1; Size of array:C274($_nodes); 1) - //Required parameters - $Dom_root:=$1 - $Txt_key:=$2 + DOM GET XML ELEMENT VALUE:C731($_nodes{$i}; $value) - //Optional parameters - If ($Lon_parameters>=3) + If (Lowercase:C14($value)=Lowercase:C14($key)) - // + return $_nodes{$i} End if - -Else - - ABORT:C156 - -End if - - // ---------------------------------------------------- -$tDom_elements{0}:=DOM Find XML element:C864($Dom_root;"/plist/dict/key";$tDom_elements) - -For ($Lon_i;1;Size of array:C274($tDom_elements);1) - - DOM GET XML ELEMENT VALUE:C731($tDom_elements{$Lon_i};$Txt_value) - - If (Lowercase:C14($Txt_value)=Lowercase:C14($Txt_key)) - - $Dom_key:=$tDom_elements{$Lon_i} - $Lon_i:=MAXLONG:K35:2-1 - - End if -End for - - // ---------------------------------------------------- - // Return -$0:=$Dom_key - - // ---------------------------------------------------- - // End \ No newline at end of file +End for \ No newline at end of file diff --git a/Project/Sources/Methods/xml_getInfoPListKey.4dm b/Project/Sources/Methods/xml_getInfoPListKey.4dm index 062d593..7c04db0 100644 --- a/Project/Sources/Methods/xml_getInfoPListKey.4dm +++ b/Project/Sources/Methods/xml_getInfoPListKey.4dm @@ -1,99 +1,52 @@ //%attributes = {"invisible":true} - // ---------------------------------------------------- - // Project method : xml_getInfoPListKey - // Database: 4D unitTest - // ID[EA1C46CA5DFB4A2482B10A976EEB3336] - // Created #14-9-2016 by Vincent de Lachaux - // ---------------------------------------------------- - // Description: - // Look for among an info.plist's elements "plist/dict/key" for name $1 - // Parameters - // $1: path of the info.plist file - // $2: name of the element - // $3: optional, pointer to C_TEXT returns the value contained in the sought key - // $0: True if the key was found, FALSE otherwise - // ---------------------------------------------------- - // Declarations -C_BOOLEAN:C305($0) -C_TEXT:C284($1) -C_TEXT:C284($2) -C_POINTER:C301($3) +// ---------------------------------------------------- +// Project method : xml_getInfoPListKey +// Database: 4D unitTest +// ID[EA1C46CA5DFB4A2482B10A976EEB3336] +// Created #14-9-2016 by Vincent de Lachaux +// ---------------------------------------------------- +// Description: +// Look for among an info.plist's elements "plist/dict/key" for name $1 +// Parameters +// $1: path of the info.plist file +// $2: name of the element +// $3: optional, pointer to C_TEXT returns the value contained in the sought key +// $0: True if the key was found, FALSE otherwise +// ---------------------------------------------------- +#DECLARE($pathname : Text; $key : Text; $response : Pointer) : Boolean -C_BOOLEAN:C305($Boo_found) -C_LONGINT:C283($Lon_parameters) -C_POINTER:C301($Ptr_value) -C_TEXT:C284($Dom_key;$Dom_root;$Dom_sibling;$File_plistPath;$Txt_key;$Txt_name) -C_TEXT:C284($Txt_value) +var $name; $node; $root; $sibling; $value : Text +var $found : Boolean -If (False:C215) - C_BOOLEAN:C305(xml_getInfoPListKey ;$0) - C_TEXT:C284(xml_getInfoPListKey ;$1) - C_TEXT:C284(xml_getInfoPListKey ;$2) - C_POINTER:C301(xml_getInfoPListKey ;$3) -End if - - // ---------------------------------------------------- - // Initialisations -$Lon_parameters:=Count parameters:C259 - -If (Asserted:C1132($Lon_parameters>=2;"Missing parameter")) +If (Asserted:C1132(Count parameters:C259>=2; Current method name:C684+": not enough parameters")) - //Required parameters - $File_plistPath:=$1 - $Txt_key:=$2 + $root:=DOM Parse XML source:C719($pathname) - //Optional parameters - If ($Lon_parameters>=3) + If (Asserted:C1132(OK=1; "Invalid XML source")) - $Ptr_value:=$3 + $node:=xml_findInfoPListKey($root; $key) - End if - -Else - - ABORT:C156 - -End if - - // ---------------------------------------------------- -If (Asserted:C1132(Count parameters:C259>=2;Current method name:C684+": not enough parameters")) - - If (Count parameters:C259>=3) - - End if - - $Dom_root:=DOM Parse XML source:C719($File_plistPath) - - If (Asserted:C1132(OK=1;"Invalid XML source")) - - $Dom_key:=xml_findInfoPListKey ($Dom_root;$Txt_key) - - If (Length:C16($Dom_key)#0) + If (Length:C16($node)#0) - $Dom_sibling:=DOM Get next sibling XML element:C724($Dom_key) - DOM GET XML ELEMENT NAME:C730($Dom_sibling;$Txt_name) + $sibling:=DOM Get next sibling XML element:C724($node) + DOM GET XML ELEMENT NAME:C730($sibling; $name) - If (Asserted:C1132(Lowercase:C14($Txt_name)="string")) + If (Asserted:C1132(Lowercase:C14($name)="string")) - $Boo_found:=True:C214 + $found:=True:C214 If (Count parameters:C259>=3) - DOM GET XML ELEMENT VALUE:C731($Dom_sibling;$Txt_value) - $Ptr_value->:=$Txt_value + DOM GET XML ELEMENT VALUE:C731($sibling; $value) + $response->:=$value End if End if End if - DOM CLOSE XML:C722($Dom_root) + DOM CLOSE XML:C722($root) End if End if - // ---------------------------------------------------- - // Return -$0:=$Boo_found - - // ---------------------------------------------------- - // End \ No newline at end of file +return $found \ No newline at end of file diff --git a/Project/Sources/Methods/xml_referenceValid.4dm b/Project/Sources/Methods/xml_referenceValid.4dm index 561eba4..cadf87b 100644 --- a/Project/Sources/Methods/xml_referenceValid.4dm +++ b/Project/Sources/Methods/xml_referenceValid.4dm @@ -1,23 +1,12 @@ //%attributes = {"invisible":true,"preemptive":"capable"} - // ---------------------------------------------------- - // Method : xml_referenceValid - // Created 27/08/10 by Vincent de Lachaux - // ---------------------------------------------------- -C_BOOLEAN:C305($0) -C_TEXT:C284($1) +// ---------------------------------------------------- +// Method : xml_referenceValid +// Created 27/08/10 by Vincent de Lachaux +// ---------------------------------------------------- +#DECLARE($node : Text) : Boolean -C_TEXT:C284($Dom_root;$Txt_buffer) +var $root : Text -If (False:C215) - C_BOOLEAN:C305(xml_referenceValid ;$0) - C_TEXT:C284(xml_referenceValid ;$1) -End if +$root:=Try(DOM Get root XML element:C1053($node)) -$Txt_buffer:=Method called on error:C704 -ON ERR CALL:C155("xml_noError") //========================== < NO ERROR > - -$Dom_root:=DOM Get root XML element:C1053($1) - -$0:=(OK=1) - -ON ERR CALL:C155($Txt_buffer) //=========================== < NO ERROR > \ No newline at end of file +return (OK=1) \ No newline at end of file diff --git a/Project/Sources/Methods/xml_remove_attribute.4dm b/Project/Sources/Methods/xml_remove_attribute.4dm index 147664e..5e94749 100644 --- a/Project/Sources/Methods/xml_remove_attribute.4dm +++ b/Project/Sources/Methods/xml_remove_attribute.4dm @@ -1,54 +1,26 @@ //%attributes = {"invisible":true,"preemptive":"capable"} - // ---------------------------------------------------- - // Project method : xml_remove_attribute - // ID[B0A9467A327349E18F9561833BE4B74F] - // Created 01/07/11 by Vincent de Lachaux - // ---------------------------------------------------- - // Description: - // Remove an attribute without error ( if exist) - // ---------------------------------------------------- - // Declarations -C_TEXT:C284($1) -C_TEXT:C284($2) - -C_LONGINT:C283($Lon_attributes;$Lon_i;$Lon_parameters) -C_TEXT:C284($Dom_element;$Txt_attribute;$Txt_name;$Txt_value) - -If (False:C215) - C_TEXT:C284(xml_remove_attribute ;$1) - C_TEXT:C284(xml_remove_attribute ;$2) -End if - - // ---------------------------------------------------- - // Initialisations -$Lon_parameters:=Count parameters:C259 - -If (Asserted:C1132($Lon_parameters>=2;Get localized string:C991("error_missingParameter"))) +// ---------------------------------------------------- +// Project method : xml_remove_attribute +// ID[B0A9467A327349E18F9561833BE4B74F] +// Created 01/07/11 by Vincent de Lachaux +// ---------------------------------------------------- +// Description: +// Remove an attribute without error ( if exist) +// ---------------------------------------------------- +#DECLARE($node : Text; $attribute : Text) + +var $name; $value : Text +var $i : Integer + +For ($i; 1; DOM Count XML attributes:C727($node); 1) - $Dom_element:=$1 - $Txt_attribute:=$2 + DOM GET XML ATTRIBUTE BY INDEX:C729($node; $i; $name; $value) -Else - - ABORT:C156 - -End if - - // ---------------------------------------------------- - -$Lon_attributes:=DOM Count XML attributes:C727($Dom_element) - -For ($Lon_i;1;$Lon_attributes;1) - - DOM GET XML ATTRIBUTE BY INDEX:C729($Dom_element;$Lon_i;$Txt_name;$Txt_value) - - If ($Txt_name=$Txt_attribute) + If ($name=$attribute) + + DOM REMOVE XML ATTRIBUTE:C1084($node; $name) - DOM REMOVE XML ATTRIBUTE:C1084($Dom_element;$Txt_name) - $Lon_i:=MAXLONG:K35:2-1 + break End if -End for - - // ---------------------------------------------------- - // End \ No newline at end of file +End for \ No newline at end of file diff --git a/Project/Sources/folders.json b/Project/Sources/folders.json index 7e8eb94..b65d1e9 100644 --- a/Project/Sources/folders.json +++ b/Project/Sources/folders.json @@ -305,7 +305,6 @@ }, "xml": { "methods": [ - "COMPILER_xml", "xml_COPY_ELEMENT", "xml_Duplicate_element", "xml_Escape_characters",