Forum

Forum breadcrumbs - You are here:ForumGeneral: Chit-chatRM8 Citation Fields
Please or Register to create posts and topics.

RM8 Citation Fields

The citation field structure has changed in RM8. In the past it included the XML header but now does not. However the XML fields in SourceTable and SourceTemplate table have not changed.

In version 7 we have

<?xml version="1.0" encoding="UTF-8"?>
<Root><Fields><Field><Name>Page</Name><Value>Class: RG10; Piece: 3167; Folio: 45; Page: 10; GSU roll: 839241</Value></Field></Fields></Root>

But in version 8 it is the simpler
<Root><Fields><Field><Name>Page</Name><Value>Class: RG10; Piece: 3167; Folio: 45; Page: 10; GSU roll: 839241</Value></Field></Fields></Root>

so any query which uses the code below to break out the field values needs amending from

-- CitationTable FIELDS parsed out from XML in a blob
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(SUBSTR(CAST(c.Fields AS TEXT),55, LENGTH(CAST(c.Fields AS TEXT))-87), '</Name>', ':'||CAST (X'09' AS TEXT)),
'<Field><Name>', ''),
'</Value>',''),
'<Value>',''),
'<Value/>',''),
'</Field>',CAST (X'0D' AS TEXT))
AS 'CitationFields',

to the following code which works for both RM7 and RM8 because in any replace, if no match is found then no replacement is made.

-- CitationTable FIELDS parsed out from XML in a blob
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(CAST(Fields AS TEXT),'</Name>', ':'||CAST (X'09' AS TEXT))
,('<?xml version="1.0" encoding="UTF-8"?>'),'')
,CAST (X'0A' AS TEXT),''),
,'<Root><Fields>',''),
'</Fields></Root>',''),
'<Field><Name>', ''),
'</Value>',''),
'<Value>',''),
'<Value/>',''),
'</Field>',CAST (X'0D' AS TEXT))
AS 'CitationFields',

 

kevync has reacted to this post.
kevync