Steven

I don’t have an exact solution for you. but the following might give you some 
pointers on the way to go. I got this code from the 4DBB-I DID NOT WRITE IT 
MYSELF. it extracts all the 4D constants from the constants xliff file.

C_POINTER($1;$constantNames_p_at)
C_POINTER($2;$constantIDs_p_at)

C_TIME($constantsXLIFFFile_h)
C_TEXT($constantsXLIFFFile_t)
C_TEXT($elementName_t;$elementPrefix_t;$constantName_t;$constantID_t)
C_BOOLEAN($transUnitFound_f;$targetFound_f)
C_LONGINT($SAXEvent_l;$pos_l)

ARRAY TEXT($attributeNames_at;0)
ARRAY TEXT($attributeVals_at;0)

$constantNames_p_at:=$1
$constantIDs_p_at:=$2

$constantsXLIFFFile_t:=(Application file)+Folder separator+"Contents"+Folder 
separator+"Resources"+Folder separator+"en.lproj"+Folder 
separator+"4D_ConstantsEN.xlf"

$constantsXLIFFFile_h:=Open document($constantsXLIFFFile_t;Read mode)

If (OK=1)

Repeat 
$SAXEvent_l:=SAX Get XML node($constantsXLIFFFile_h)
Case of 

: ($SAXEvent_l=XML start element)
SAX GET XML ELEMENT($constantsXLIFFFile_h;$elementName_t;\
$elementPrefix_t;$attributeNames_at;$attributeVals_at)

  // Need to locate the "target" element for each constant "trans-unit".
Case of 
: ($elementName_t="trans-unit")
$pos_l:=Find in array($attributeNames_at;"id")
If ($pos_l>0)
$constantID_t:=$attributeVals_at{$pos_l}
  // Ignore the first trans-unit in each group, it's not a constant.
If ($constantID_t#"@_0")
$transUnitFound_f:=True
$constantID_t:=Substring($constantID_t;3)
Else 

End if 
End if 

: ($elementName_t="target")
If ($transUnitFound_f)
$targetFound_f:=True
$transUnitFound_f:=False
End if 
End case 

: ($SAXEvent_l=XML DATA)
  // With the target located, we have the constant name.
If ($targetFound_f)
SAX GET XML ELEMENT VALUE($constantsXLIFFFile_h;$constantName_t)
APPEND TO ARRAY($constantNames_p_at->;$constantName_t)
APPEND TO ARRAY($constantIDs_p_at->;Num($constantID_t))
$constantName_t:=""
$constantID_t:=""
$targetFound_f:=False
End if 

End case 
Until ($SAXEvent_l=XML end document)

CLOSE DOCUMENT($constantsXLIFFFile_h)
End if 

> On 9 Mar 2017, at 02:07, Steven via 4D_Tech <[email protected]> wrote:
> 
> Miyako’s reply confirms that RESOURCE LIST does not work with XLIFF files, as 
> I suspected.  
> 
> So having extracted my STR# resources into XLIFF files (with the help of 
> Miyako's component, thanks again), what I would like to do is replicate its 
> functionality, i.e. extract arrays of the ‘ids’ and ’resnames’ of all of the 
> ‘group’ elements present within those XLIFF files.  I am confident that that 
> can be done, but as I said I am entirely out of my depth with respect to XML 
> and native 4D XML commands.  
> 
> Any direction, better yet, sample code would be greatly appreciated.  
> 
> Thanks in advance.
> 
> Steven Prins
> Santa Fe, NM
> 
> 
>> On Mar 8, 2017, at 3:32 AM, [email protected] wrote:
>> 
>> Message: 3
>> Date: Wed, 8 Mar 2017 03:08:52 +0000
>> From: Keisuke Miyako <[email protected] <mailto:[email protected]>>
>> To: 4D iNug Technical <[email protected] <mailto:[email protected]>>
>> Subject: Re: RESOURCE LIST & XLIFF Resource Files
>> Message-ID: <[email protected] 
>> <mailto:[email protected]>>
>> Content-Type: text/plain; charset="utf-8"
>> 
>> Hello,
>> 
>> the command RESOURCE LIST was never associated with XLIFF.
>> 
>> resource commands that work with XLIFF are:
>> 
>> STRING LIST TO ARRAY
>> http://doc.4d.com/4Dv15/4D/15.4/STRING-LIST-TO-ARRAY.301-3274706.en.html 
>> <http://doc.4d.com/4Dv15/4D/15.4/STRING-LIST-TO-ARRAY.301-3274706.en.html>
>> 
>> and
>> 
>> Get indexed string
>> http://doc.4d.com/4Dv15/4D/15.4/Get-indexed-string.301-3274707.en.html 
>> <http://doc.4d.com/4Dv15/4D/15.4/Get-indexed-string.301-3274707.en.html>
>> 
>> see also:
>> 
>> Appendix C: XLIFF architecture
>> http://doc.4d.com/4Dv15/4D/15.4/Appendix-C-XLIFF-architecture.300-3285323.en.html
>>  
>> <http://doc.4d.com/4Dv15/4D/15.4/Appendix-C-XLIFF-architecture.300-3285323.en.html>
>> 
>>> 2017/03/08 1:22、Steven via 4D_Tech <[email protected] 
>>> <mailto:[email protected]>> のメール:
>>> Does the 4D command “RESOURCE LIST” still work with XLIFF string resource 
>>> files?
>> 
> 
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to