Did you know that you can call SPARQLMotion modules such as ExportToXMLFile 
from SWP? Since you’re already familiar with SWP, I would recommend using that 
way. Staying in SWP gives you better control over the details, and more power.

As an experiment, I added a new ui:Services subclass with ui:responseType 
ui:TEXT and the following ui:prototype:

<ui:group let:outfile="/Test/out.xml">
    <ui:bind>
        <ui:stringify ui:format="ui:XML" ui:varName="output">
            <geographyOutput:getOutput/>
        </ui:stringify>
        <sml:ExportToXMLFile sml:targetFilePath="{= ?outfile }" sml:xml="{= 
?output }"/>
        <ui:group>XML output written to {= ?outfile }</ui:group>
    </ui:bind>
</ui:group>

This service calls the existing getOutput SWP script, turns its result into a 
string, writes the string to an XML file, and returns a simple success message 
to the calling browser/client. In my test, this seemed to handle special 
characters correctly.

For best compatibility, the resulting XML file should probably start with an 
XML declaration that sets the encoding to UTF-8, but that could easily be added 
ExportToXMLFile call:

    sml:xml="&lt;?xml … ?&gt;{= ?output }"

Richard



> On 13 Feb 2019, at 16:59, Sanjeev Devireddy <[email protected]> 
> wrote:
> 
> Hi Richard,
>    The solution of using <ui:return> works. But, the end goal is to write the 
> generated XML output to a local file. So, I created a SPARQLMotionscript with 
> two stages CreateSWPDocument & ExportToXMLFile. The CreateSWPDocument has the 
> code(this example refers to the Geography Taxonomy that comes by default with 
> the TopBraid EDG application, with a recursive function, as like in previous 
> example) to generate the XML output and the ExportToXMLFile writes the output 
> to local folder. In this script, I again see that the special characters are 
> not rendered properly in the process of writing the output to a local file. I 
> added a third stage ExportToTextFile, just to see whether CreateSWPDocument 
> is generating some output or not. Please find the 
> attachment(testGeoScript.ttl) for the SPARQLMotion script file. Could you 
> please suggest a solution for this?
> 
> Note: Regarding the global variable in a recursive function, for now it is 
> working and yes, I need to change that code snippet.
> 
> Thanks,
> Sanjeev
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> <testGeoScript.ttl>

-- 
You received this message because you are subscribed to the Google Groups 
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to