Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when loading dai-debt.xml #1

Open
SmartLayer opened this issue Aug 7, 2020 · 6 comments
Open

error when loading dai-debt.xml #1

SmartLayer opened this issue Aug 7, 2020 · 6 comments

Comments

@SmartLayer
Copy link

SmartLayer commented Aug 7, 2020

Access debt-dai.xml

Observe the IFRAMEs are empty and there is an error

Uncaught ReferenceError: loadIframe is not defined.

Later I realised that the debugger assumes the JS fiel to be in the same places as the TokenScript XML file, while I put the debuger (both xsl and js files) into a subfolder, hance the <script src="…" didn't work.

Suggested workaround:

In this version:

https://alphawallet.github.io/TokenScript-Examples/examples/AAVE/debt-dai.xml

I put JavaScript inside the xslt file:

                        <script type="text/javascript" charset="utf-8">
//<![CDATA[
function loadIframe(){
        var iframes = document.getElementsByTagName("iframe");
        for(var i=0; i<iframes.length; i++){
                var iframe = iframes[i];
                var textContent = iframe.textContent;
                var wrapper = document.createElement('div');
                wrapper.innerHTML = textContent;
                
                iframeContentDocument = iframe.contentDocument || iframe.contentWindow.document;
                iframeContentDocument.write(wrapper.innerHTML);
                iframe.textContent = "";
        }

}
//]]>
                </script>

Do you accept this as a solution?

@darakhbharat
Copy link
Owner

darakhbharat commented Aug 7, 2020 via email

@SmartLayer
Copy link
Author

SmartLayer commented Aug 7, 2020

Does entity reference work in XSLT file? I think it might does. If it does, you should be able to

  1. Save a .js file with the following:
//<![CDATA[
function loadIframe(){
        var iframes = document.getElementsByTagName("iframe");
        for(var i=0; i<iframes.length; i++){
                var iframe = iframes[i];
                var textContent = iframe.textContent;
                var wrapper = document.createElement('div');
                wrapper.innerHTML = textContent;
                
                iframeContentDocument = iframe.contentDocument || iframe.contentWindow.document;
                iframeContentDocument.write(wrapper.innerHTML);
                iframe.textContent = "";
        }

}
//]]>
  1. refer to them as an entity inside the <script>…</script>?

I'm not sure if entity dereference works on the web, but if it does, it would be great.

@darakhbharat
Copy link
Owner

darakhbharat commented Aug 7, 2020 via email

@SmartLayer
Copy link
Author

SmartLayer commented Aug 7, 2020

FF has below settings like Chrome to run the XSLT locally.

Which is true?

  • FF categorically doesn't recognise entity reference ;
  • FF doesn't recognise entity reference when it's served on the web.

I am still checking ways to make it work on FF, Chrome seems best till then.

Yeah, will try to get by with Chrome for now. FYI we will not always be using entity references - we wanted to allow either entity reference or Object/Manifest since 1.5 years ago but never got around to implemente support for loading views from there.

@darakhbharat
Copy link
Owner

darakhbharat commented Aug 7, 2020 via email

@darakhbharat
Copy link
Owner

Hi Weiwu,

The original issue 1 here is resolved and committed changes to - https://github.com/darakhbharat/TokenScript-debugger

Now you only need to take ts-debugger.xsl file which also has required JS code.


Now regarding FF one more stackoverflow thread says that right now external entity not supported in FF.
https://stackoverflow.com/questions/1512747/will-firefox-do-xslt-on-external-entities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants