Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XmlToCursor() to ignore the XSD
Message
 
 
À
15/02/2020 15:56:37
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Divers
Thread ID:
01673054
Message ID:
01673069
Vues:
43
I used a copy of the XML file that I have which includes this reference (when posting initial message here). I don't remember why I put it into the XML file in the first place (years ago). And since I am the only person who put this XML into the customers installations, this is it. So, your example with "xsi" is all I have to deal with.

>One more thing, Dmitry.
>
>I assumed in my demo that the XML Schema namespace is always being referred to through the "xsi" prefix (as it was in the example you gave, following what is not a standard but rather a common practice in the XML authoring community). The prefix may be different in some documents, nevertheless. If that happens to be the case, the demo must be modified for increased robustness.
>
>>Antonio,
>>Thank you very much!
>>
>>>Yes, Dmitry, you could do something like this:
>>>
>>>
>>>IF m.NoXSD.selectNodes("/Doc/attribute::*[name() = 'xsi:noNamespaceSchemaLocation']").length = 1
>>>	m.NoXSD.selectNodes("/Doc").item(0).removeAttribute("xsi:noNamespaceSchemaLocation")
>>>ENDIF
>>>
>>>
>>>>Antonio,
>>>>
>>>>I was wondering, is it possible to check - programmatically - if the XSD reference exists in the XML file? This way, before I apply your code to remove the reference for XSD file, I can check if it exists.
>>>>
>>>>Does it make sense?
>>>>
>>>>>Dmitry,
>>>>>
>>>>>You can remove programmatically the attribute that holds the schema location and pass to XMLTOCURSOR() a no-schema version of the document.
>>>>>
>>>>>A demo:
>>>>>
>>>>>
>>>>>LOCAL Source AS String
>>>>>
>>>>>TEXT TO m.Source NOSHOW FLAGS 1
>>>>><?xml version="1.0" encoding="utf-8"?>
>>>>><Doc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>>>>>	xsi:noNamespaceSchemaLocation="NonExisting.xsd">
>>>>>	<Row>
>>>>>		<Column_1>Joseph</Column_1>
>>>>>		<Column_2>25</Column_2>
>>>>>	</Row>
>>>>>	<Row>
>>>>>		<Column_1>Mary</Column_1>
>>>>>		<Column_2>27</Column_2>
>>>>>	</Row>
>>>>></Doc>
>>>>>ENDTEXT
>>>>>
>>>>>LOCAL NoXSD AS MSXML2.DOMDocument60
>>>>>
>>>>>m.NoXSD = CREATEOBJECT("MSXML2.DOMDocument.6.0")
>>>>>m.NoXSD.Async = .F.
>>>>>m.NoXSD.LoadXML(m.Source)  && when m.Source is a file name, use Load() instead
>>>>>
>>>>>m.NoXSD.selectNodes("/Doc").item(0).removeAttribute("xsi:noNamespaceSchemaLocation")
>>>>>
>>>>>XMLTOCURSOR(m.NoXSD.XML)
>>>>>
>>>>>
>>>>>>Hi,
>>>>>>
>>>>>>Is it possible to make the VFP function XMLTOCURSOR() to ignore the XSD file in the .XML?
>>>>>>
>>>>>>I have a case where many XML files (not used by VFP but by a .NET application) have the XSD. Here is an example of a top of such XML file:
>>>>>>
>>>>>><?xml version="1.0" encoding="utf-8" ?>
>>>>>><EmailList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>>>>>>	xsi:noNamespaceSchemaLocation="EmailList.xsd" >
>>>>>>	<Contact>
>>>>>>		<FirstName>John</FirstName>
>>>>>>
>>>>>>
>>>>>>What happens is .NET has not problem that the XML file references an XSD file but the EmailList.xsd does not exit. .NET opens this XML and converts to dataset without any issues.
>>>>>>But when I try to use this XML from VFP, I get an error. One option for me is to manually remove the reference to the XSD file from each customer. Some work.
>>>>>>But if there is a way to make the VFP function ignore the reference to XSD, it would be better.
>>>>>>
>>>>>>TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform