Hi @lmoeller , could you please post the value (XML formatted text?) of the attribute called "SCIENTIST_INFORMATION" and the template expression which you have set to the XMLTemplater?
Hi @Takashi Iijima ,
of course I can - I thought it might clutter up the thread too much.
Here is the XML insert:
<mri:pointOfContact xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">
<cit:CI_Responsibility>
<cit:role>
<cit:CI_RoleCode codeList="https://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_RoleCode"
codeListValue="originator">originator</cit:CI_RoleCode>
</cit:role>
<cit:party>
…
</cit:party>
</cit:CI_Responsibility>
</mri:pointOfContact>
@Takashi Iijima Anything else I could provide to further this?
@Takashi Iijima Anything else I could provide to further this?
As far as I see the XML and the template expression you have posted, I can't find anything wrong. According to the error message, however, it seems that the issue occurred while executing the fme:get-xml-attribute function. Possibly the error could be hidden in the part you have omitted in the posted documents.
As far as I see the XML and the template expression you have posted, I can't find anything wrong. According to the error message, however, it seems that the issue occurred while executing the fme:get-xml-attribute function. Possibly the error could be hidden in the part you have omitted in the posted documents.
Hi @Takashi Iijima ,
sorry for not coming back to this earlier. I had a few weeks off for vacation and other projects. But I'd still love to solve this little showstopper. And, if I am lucky, with the help of your support.
It is strange, I checked for other fme:get-xml-attribute calls in the root template and couldn't find any. And the respective insert is the only one omitted in the templater output afaics.
However, for your reference, I attached the full document (needed depersonalization still).
Hopefully you have an idea, I surely don't.
My best regards and warmest thanks!
lmoeller
I wasn't able to reproduce the error with the template expression you have posted, but the same error occured once I added an extra character (e.g. a comma) at the end of the value of "SCIENTIST_INFO_LIST-ISO2014" (the xml document to be inserted with the fme:get-xml-attribute function).
XMLTemplater (XMLTemplaterFactory): The following error occurred while executing the fme:get-xml-attribute function:
XMLTemplater (XMLTemplaterFactory): The following error occurred near line 1, column 51 of the query:
XMLTemplater (XMLTemplaterFactory): invalid content passed to fn:parse-xml(): loader parsing error: Extra content at the end of the document
Please validate again the XML document stored in the "SCIENTIST_INFO_LIST-ISO2014".
What I have done in the past is do the merge outside of the XMLTemplater. So just have a placeholder string in the XMLTemplater and then use a StringReplacer to swap that out with the XML you want added in.
I wasn't able to reproduce the error with the template expression you have posted, but the same error occured once I added an extra character (e.g. a comma) at the end of the value of "SCIENTIST_INFO_LIST-ISO2014" (the xml document to be inserted with the fme:get-xml-attribute function).
XMLTemplater (XMLTemplaterFactory): The following error occurred while executing the fme:get-xml-attribute function:
XMLTemplater (XMLTemplaterFactory): The following error occurred near line 1, column 51 of the query:
XMLTemplater (XMLTemplaterFactory): invalid content passed to fn:parse-xml(): loader parsing error: Extra content at the end of the document
Please validate again the XML document stored in the "SCIENTIST_INFO_LIST-ISO2014".
Ahh, we have a new lead! There are a few datasets were the incoming "SCIENTIST_INFO_LIST-ISO2014" only contains information of one person - in these cases the templater function actually works.
However, in most of the cases the"SCIENTIST_INFO_LIST-ISO2014" contains two or more scientists. And then "SCIENTIST_INFO_LIST-ISO2014" insert might look like this:
<mri:pointOfContact xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">
<cit:CI_Responsibility>
…
</cit:CI_Responsibility>
</mri:pointOfContact> <mri:pointOfContact xmlns:mdb="http://standards.iso.org/iso/19115/-3/mdb/2.0"
xmlns:cit="http://standards.iso.org/iso/19115/-3/cit/2.0"
xmlns:mri="http://standards.iso.org/iso/19115/-3/mri/1.0"
xmlns:gco="http://standards.iso.org/iso/19115/-3/gco/1.0">
<cit:CI_Responsibility>
…
</cit:CI_Responsibility>
</mri:pointOfContact>
I suppose the missing root element and/or double namespace declarations in these cases makes the templater fail.
Will I have to split the insert into multiple parts and add them with the appropriate amount of templaters or could I manage it in a loop construction (like fn:tokenize)). But what could be the delimiter in the case? Would you think that "</mri:pointOfContact> <mri:pointOfContact" might work?
Thanks again, @takashi
What I have done in the past is do the merge outside of the XMLTemplater. So just have a placeholder string in the XMLTemplater and then use a StringReplacer to swap that out with the XML you want added in.
Why didn't I think of that? Simple and effective - and works! Thanks for sharing!
I wasn't able to reproduce the error with the template expression you have posted, but the same error occured once I added an extra character (e.g. a comma) at the end of the value of "SCIENTIST_INFO_LIST-ISO2014" (the xml document to be inserted with the fme:get-xml-attribute function).
XMLTemplater (XMLTemplaterFactory): The following error occurred while executing the fme:get-xml-attribute function:
XMLTemplater (XMLTemplaterFactory): The following error occurred near line 1, column 51 of the query:
XMLTemplater (XMLTemplaterFactory): invalid content passed to fn:parse-xml(): loader parsing error: Extra content at the end of the document
Please validate again the XML document stored in the "SCIENTIST_INFO_LIST-ISO2014".
The "SCIENTIST_INFO_LIST-ISO2014" should be a single XML fragment. Missing a common parent (root) element of the multiple mri:pointOfContact elements was reason for the error.
A simple workaround is: create a single XML element that contains the multiple mri:pointOfContact elements and store it as a new attribute (e.g. named "_scientist_infos") with the AttributeCreator or the StringConcatenator,
<infos>
@Value(SCIENTIST_INFO_LIST-ISO2014)
</infos>
then embed this expression into the template expression to insert the child elements (i.e. multiple mri:pointOfContact).
{
for $x in fme:get-xml-attribute("_scientist_infos")/infos/mri:pointOfContact
return $x
}
The "SCIENTIST_INFO_LIST-ISO2014" should be a single XML fragment. Missing a common parent (root) element of the multiple mri:pointOfContact elements was reason for the error.
A simple workaround is: create a single XML element that contains the multiple mri:pointOfContact elements and store it as a new attribute (e.g. named "_scientist_infos") with the AttributeCreator or the StringConcatenator,
<infos>
@Value(SCIENTIST_INFO_LIST-ISO2014)
</infos>
then embed this expression into the template expression to insert the child elements (i.e. multiple mri:pointOfContact).
{
for $x in fme:get-xml-attribute("_scientist_infos")/infos/mri:pointOfContact
return $x
}
Awesome @Takashi Iijima - that did the trick!
And again, I could even learn a thing or two, so I think its even a better solution than the one of @Gary Nicholson
Nevertheless, thanks to both of you once again!