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

Ignore XML validation errors on read #141

Open
petri4kov opened this issue Jul 3, 2018 · 4 comments
Open

Ignore XML validation errors on read #141

petri4kov opened this issue Jul 3, 2018 · 4 comments
Labels

Comments

@petri4kov
Copy link

Hi guys!

I was thinking of using the sabre xml parser for a project, and downloaded it and included it in the project, but when I tried parsing my xml file, it turned out validation errors are stopping it of getting it parsed.

Now, my xml file is a custom one, and I'm aware it works, and even if it's not valid by standard I need it looking that exact way.

So my question is, can I give the Service class a parameter to ignore errors, as I would in SimpleXML? Like that:
simplexml_load_file(file, "SimpleXMLElement", LIBXML_NOERROR | LIBXML_ERR_NONE);

Sorry if the question is dumb :)
Thank you in advance for the help!

Best,
Kostadin

@evert
Copy link
Member

evert commented Jul 3, 2018

Hi @petri4kov .

I'm not 100% sure if this is possible. Of course I would first recommend to try to fix the source xml, instead of the reader. Strict = good =)

Can you tell me more about the error you're getting?

@evert evert added the question label Jul 3, 2018
@petri4kov
Copy link
Author

Hi @evert,

Unfortunately for me fixing the xml file is not an option - we've got an internal system that reads this specific form of invalid xml, and will throw another kind of errors if I try my hand at fixing it :/

Otherwise, in the opening tag of the document, I've got an attribute called
ss:disableBackButton="1"
Sabre XML says that ss has not been defined as a namespace, and is correct. But this is the way the internal system was tailored to work and I can't change it.

My viable option here is to somehow tell the Reader class to ignore the validity of the xml file if possible.
Either way, I had a look at the Reader class in the sabrexml source, but if I override it now, with the next update it will go back to its original state.

Best,
Kostadin

@evert
Copy link
Member

evert commented Jul 3, 2018 via email

@petri4kov
Copy link
Author

Um, do you mean the first line of the xml file?
If that's what you mean - the first line the xml declaration, and it would also throw an error, but what I did was to delete it, so I can continue experimenting.

This is how the start of the xml looks:

<?xml version="1.1.1" encoding="UTF-8"?>
<survey
name="Survey"
alt="INSERT NAME HERE"
autosave="1"
autosaveKey="i,ac,source,RID"
extraVariables="source,list,url,exitURL,record,ipAddress,userAgent,panelPartnerId,l,countryCode,i,batchno,test,ac,sn,lang,gmid,gh,netMRsrc,sourceid,x,y,uid,sampleSource"
compat="138"
state="testing"
setup="time,quota,term"
ss:disableBackButton="1"
displayOnError="all"
unique=""
newStyle="1"
unmacro="0"
trackVars="checkbox"
autoRecover="1"
mobile="compat"
mobileDevices="smartphone,tablet"
persistentExit="1"
company="LSR EMEA"
uses="qastyler.1"
qa:template="4a"
ssc:enable="1"
>

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

No branches or pull requests

2 participants