Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recordset to Cursor
Message
De
22/02/2006 17:16:00
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01098156
Message ID:
01098290
Vues:
17
What about this solutione:
1. replace "/>" with some never used character, like chr(255), using strtran
2. replace the leftover "/", which causes the problem, by chr(254) using chrtran
3. replace chr(255) with "/>" using strtran
4. xmltocursor
5. replace chr(254) with "/" in your cursor
1,2,3 and 4 can be done in one long, ugly line, as far as I can see.

>Yeah Tore, that's what I was thinking at first... however besides the fact that the xml never gets created by the recordset save method, the characters I need to escape are forward slashes - the same as the ending tags of the XML. So to do this after the XML gets created (which it doesn't) I'd need some a regular expression to figure out what was an ending tag and what was part of an URL. It appears that I will need to loop through the recordset and escape the characters manually... however the presents me with two problems... 1. Speed 2. What if I have a firehose recordset where there is no way to go backwards. Either way it is looking more and more like some sort of really ugly hack is going to be the order of the day unless there is another way to create a cursor from a recordset that hasn't already been explored. If nothing else, I've learned a great deal from the techniques that were shown by Sergey, Borislav, and Cetin. If I had any control over these recordset objects and how
>they get created or they were somewhat simpler all of these techniques would work great.
>
>When I started on this today, I didn't think it was going to be quite so difficult... had I known then what I know now I would have outsourced it. LOL
>
>>Hi Craig,
>>
>>have you tried to filter out the unsafe characters with chrtran?
>>xmltocursor(chrtran(filetostr("myTemp.xml"),'xzy',''),'myCursor',0)
>>
>>>>Craig,
>>>>Since you have data to test with, try with another flag excluding 1024 (say 0 or 4 only). Also you can try an alternative:
>>>>
>>>>oRS.Save("mytemp.xml",1)
>>>>xmltocursor("myTemp.xml",'myCursor',512)
>>>>
>>>
>>>No difference, already had tried the 4 and 0, and as for creating the file on disk it is noticeably slower and same problem. I sure wish that Microsoft had put a method on the recordset or the DOMDocument that would allow for escaping these XML unsafe characters. I'm a little surprised that it's not there to be honest. Since the XML never gets created on the Save method of the recordset there's no way I can see to fix this besides a rather clumsy hack... I hate hacks, but they're better than no solution at all. Perhaps you're right, that a better solution is still out there. I'll keep my fingers crossed and the stars for you in case nothing comes through by later tonight. Thanks again Cetin... if you get any other ideas I'm all ears.
>>>
>>>>PS: I never mind about stars:) Keep as is so a better solution might come.
>>>>Cetin
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform