Closed ghost closed 9 years ago
Can you post a complete minimal working example with the XML file?
This is the contents of the b.xml
. With other contents, I can't get any error:
<?xml version="1.0" standalone='yes'?>
<activitats>
<activitat id="fitxes" tema="funcions" continguts="funció afí, dependència lineal, funcions a trossos">
<presentacio tipus="tradicional" sintaxi="context" verbs="calcular">La fitxa blava i la fitxa vermella es mouen de la manera següent: la blava recorre les caselles d'una en una, mentre que la vermella les recorre de dues en dues però, després de cada moviment, s'espera un torn (figura~\in[]). Quina de les dues fitxes arribarà primer a la meta?
</presentacio>
<presentacio tipus="3-act" sintaxi="html" verbs="modelitzar">
<actes>
<u>vídeo fitxes</u>
<dos></dos>
<tres></tres>
</actes>
</presentacio>
</activitat>
</activitats>
I don't have python3, but with python 2.7.8, the following works fine:
\usemodule[filter]
\traceexternalfilters
\defineexternalfilter
[python]
[filtercommand={python \externalfilterinputfile\space > \externalfilteroutputfile}, location=text,
cache=no]
\startbuffer[data]
<?xml version="1.0" standalone='yes'?>
<activitats>
<activitat id="fitxes" tema="funcions" continguts="funció afí, dependència lineal, funcions a trossos">
<presentacio tipus="tradicional" sintaxi="context" verbs="calcular">La fitxa blava i la fitxa vermella es mouen de la manera següent: la blava recorre les caselles d'una en una, mentre que la vermella les recorre de dues en dues però, després de cada moviment, s'espera un torn (figura~\in[]). Quina de les dues fitxes arribarà primer a la meta?
</presentacio>
<presentacio tipus="3-act" sintaxi="html" verbs="modelitzar">
<actes>
<u>vídeo fitxes</u>
<dos></dos>
<tres></tres>
</actes>
</presentacio>
</activitat>
</activitats>
\stopbuffer
\savebuffer[list=data, file=b.xml, prefix=no]
\starttext
\startpython
import os.path
with open('./b.xml', 'r') as f:
r = f.read()
print(len(r))
\stoppython
\stoptext
Here not, with python2 and python3. I don't know why!
Can you post the complete log file that you get when running my example?
On Aug 4, 2015, 12:15 PM, at 12:15 PM, Xavier notifications@github.com wrote:
Here not, with python2 and python3. I don't know why!
Reply to this email directly or view it on GitHub: https://github.com/adityam/filter/issues/22#issuecomment-127662548
In the first example (in your original bug report) you use print(len(r))
but in the second example (the one in your repo) you use print(r)
. So, the entire contents of your xml
file are input as if you had literally typed them in your tex
file. This means that you are compiling a tex
file:
\starttext
..... \in[] ....
\stoptext
The error message:
references > start problematic references
references > unknown > 1: [][]
references > stop problematic references
is telling you that <empty string>
reference was not found.
With this
\startpython
from bs4 import BeautifulSoup
import json, os.path
with open('./dades/activitats.xml', 'r') as f:
r = f.read()
print(len(r))
# soup = BeautifulSoup(r, "xml")
#
# for a in soup.find_all("activitat", {'id': 'fitxes'}):
# for p in a.find_all("presentacio"):
# print(p.text)
\stoppython
I obtained the same result (empty string). What can I do=?
.tuc
file and try again..tuc
file and add
\traceexternalfilters
. This will not remove the \jobname-temp-*.tmp
file. Open this file in an editor to see that it is written correctly. Run
it through python to ensure that you are getting correct output.On Sat, 8 Aug 2015, Xavier wrote:
With this
\startpython from bs4 import BeautifulSoup import json, os.path with open('./dades/activitats.xml', 'r') as f: r = f.read() print(len(r)) # soup = BeautifulSoup(r, "xml") # # for a in soup.find_all("activitat", {'id': 'fitxes'}): # for p in a.find_all("presentacio"): # print(p.text) \stoppython
I obtained the same result (empty string). What can I do=?
Reply to this email directly or view it on GitHub: https://github.com/adityam/filter/issues/22#issuecomment-128977977
add
\traceexternalfilters
where?
See the example that I had posted.
On Aug 8, 2015, 10:35 AM, at 10:35 AM, Xavier notifications@github.com wrote:
add
\traceexternalfilters
where?
Reply to this email directly or view it on GitHub: https://github.com/adityam/filter/issues/22#issuecomment-128987366
I do not understand nothing.
Let's do simply example:
\startpython
import yaml
print("\startitemize")
with open('dades/accions.yaml', 'r') as f:
r = yaml.load(f)
print(r)
for a in r:
print("\item {0}".format(a))
print("\stopitemize")
\stoppython
This gives me blank string. How can I modify it for proper printing?
Thanks,
Does this run correctly if you save the contents as a python file and compile it?
On Aug 9, 2015, 5:38 AM, at 5:38 AM, Xavier notifications@github.com wrote:
Let's do simply example:
\startpython import yaml
print("\startitemize")
with open('dades/accions.yaml', 'r') as f: r = yaml.load(f) print(r) for a in r: print("\item {0}".format(a))
print("\stopitemize")
\stoppython
This gives me blank string. How can I modify it for proper printing?
Thanks,
Reply to this email directly or view it on GitHub: https://github.com/adityam/filter/issues/22#issuecomment-129145168
Yes
I don't know why this is not working. Can you create a complete and minimal example that does not work (similar to the one that I created in my comment above
Ruby does not do that. Perfect with ruby.
With this filter:
and this code:
all is fine except when b.txt is an XML file. I get this
What happens?