Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Integration > XDTOFactory, attribute schemaLocation. How?

Forum

Search UsersRules
XDTOFactory, attribute schemaLocation. How?
#1
Just came
Points:: 0
Joined:: Jan 23, 2013

Hello all.

The problem is that it is impossible to specify the type like this:

Quote
type_schemaLocation = XDTOFactory.Type("http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
How to assign attribute type schemaLocation ?

Quote
The xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes can be used in a document to provide hints as to the physical location of schema documents which may be used for ·assessment·. See How schema definitions are located on the Web (§4.3.2) for details on the use of these attributes.

Profile
#2
Active user
Points:: 0
Joined:: Sep 26, 2012

Maybe this will help you.
I add xdto package with Namespace Uri "http://www.w3.org/2001/XMLSchema-instance"
and then create type in DataProcessor1 at Server Procedure.
see my example.

Profile
#3
Just came
Points:: 0
Joined:: Jan 23, 2013

Thanks for the tip, but there are two problems:
1) schemaLocation this is attribute. The suggested option - complex Type in XML.
2) But even if the schemaLocation a simple type, then this Namespace ("http://www.w3.org/2001/XMLSchema-instance") import in other XDTO package
and 1С platform output does so:

Quote
<ITMList xmlns="http://www.otto.de/itemdist" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.otto.de/itemdist itm_list.xsd">
whitout prefix xsi, but should be like this:
Quote
<ITMList xmlns="http://www.otto.de/itemdist" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.otto.de/itemdist itm_list.xsd">

I may be doing something wrong?

Profile
#4
Active user
Points:: 2
Joined:: Sep 16, 2011

Try using SetAttribute method of DOMElement:

SetAttribute(<Name>, <Value>)
SetAttribute(<NamespaceURI>, <LocalName>, <Value>)

Sets an attribute value.
If the attribute with the specified name does not exist in the element, it is created and set to the specified value. Otherwise, the attribute value is changed. The attribute value is not parsed while it is set

If the attribute name contains characters incompatible with XML standard of this document, or the node is read-only, an exception is triggered.

Profile
#5
Just came
Points:: 0
Joined:: Jan 23, 2013

Xin Wang, please give an example
I have the XDTOobject
how convert XDTOobject to DOMElement?

Profile
#6
Active user
Points:: 2
Joined:: Sep 16, 2011

Let's do opposite: please provide the infobase dump and explain where is the problem in it. And we will try to help.

Profile
#7
Just came
Points:: 0
Joined:: Jan 23, 2013

Ok. This database: http://sdrv.ms/YqlS9p
formed XML:

Code
<ITMList 
xmlns="http://www.sample-package.org" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <one>Fire</one>
   <zero>Bomb</zero>
</ITMList>


How to make sure that the element "ITMList"
containing the attribute "xsi:schemaLocation="http://www.otto.de/itemdist itm_list.xsd"
?

Profile
#8
Active user
Points:: 0
Joined:: Nov 19, 2012

Alexey, if I understood you correctly - you want get something like this:

Code
<ITMList xmlns="http://www.sample-package.org" 
xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
schemaLocation="http://www.otto.de/itemdist/itm_list.xsd">
   <zero>Bomb</zero>
</ITMList>


You wrote correct code:
Code
ITMList = XDTOFactory.Create(XDTOFactory.Type("http://www.sample-package.org","ITMList"));
   ITMList.schemaLocation = "http://www.otto.de/itemdist/itm_list.xsd";
   ITMList.zero = "Bomb";


but in XDTOPackage for schemaLocation you must set Form=Attribute (default = Item)


But I don't know how to add prefix xsi..

Profile
#9
Just came
Points:: 0
Joined:: Jan 23, 2013

Thank you Aleksey for the analysis! )))

Quote
but in XDTOPackage for schemaLocation you must set Form=Attribute (default = Item)
According to the XML specification
http://www.w3.org/TR/xmlschema-1/#no-xsi
you suggested incorrect variant ((

and yes, need only:
Code
xsi:schemaLocation="http://www.otto.de/itemdist/itm_list.xsd"

Profile
#10
Active user
Points:: 2
Joined:: Sep 16, 2011

I tried to add xsi to schemaLocation, but failed too. Did this without of using XDTO Factory:

Code
   TempFileName = GetTempFileName();
   
   XMLWriter = New XMLWriter;
   XMLWriter.OpenFile(TempFileName);
   XMLWriter.WriteXMLDeclaration();
   XMLWriter.WriteStartElement("ITMList");
   XMLWriter.WriteAttribute("xmlns", "http://www.otto.de/itemdist");
   XMLWriter.WriteAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema");
   XMLWriter.WriteAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
   XMLWriter.WriteAttribute("xsi:schemaLocation", "http://www.otto.de/itemdist/itm_list.xsd");
   WriteXML(XMLWriter, "Fire", "one");
   WriteXML(XMLWriter, "Bomb", "zero");
   XMLWriter.WriteEndElement();
   XMLWriter.Close();
   
   XMLtext.Read(TempFileName);

Profile
#11
Just came
Points:: 0
Joined:: Jan 23, 2013

Thank you, Xin Wang!

But we must using XDTOFactory for this. How?..........
Guess platform can not this...

Profile
#12
Guest
Points::
Joined::

I have requested additional information regarding this topic from our developers and will notify you later.

Profile
#13
Guest
Points::
Joined::

Alexey, unfortunately it is not possible to set schemaLocation using XDTO package. I can suggest you to use the solution provided by Xin Wang or process the resulting file, generated with usage of XDTOPackage and containing no schemaLocation, using XMLReader and XMLWriter to add schemaLocation where it is needed.

If you can give reasons that support of schemaLocation is critical for you and other users, I will send your request to our developers.

Profile
#14
Just came
Points:: 0
Joined:: Jan 23, 2013

Quote
If you can give reasons that support of schemaLocation is critical for you and other users, I will send your request to our developers.
XDTOFactory can not do
that inherent in XML standard
this is the reason

Timofey Bugaevsky, thanks for the reply and help.

Profile
#15
Guest
Points::
Joined::

Our developers said that this is not the often used functionality due to the development and data should be separated.

Profile
#16
Interested
Points:: 15
Joined:: Oct 27, 2011

Quote
Timofey Bugaevsky wrote:
If you can give reasons that support of schemaLocation is critical for you and other users, I will send your request to our developers.

1.2.28. Instance document must use the same namespace prefixes as used in the XBRL schemas or conformance suite instances together with the recommended default namespace prefix for all namespaces.

Below is a list of XBRL schemas for the core document files that are supported by disclosure systems following Global Filing Manual (e.g. instance, linkbase, XLink documents). The namespace that represents each document must be used in the form as shown. A recommended prefix that represents each namespace is provided. The location of the actual schema file is also identified.

http://www.ifrs.org/NR/rdonlyres/ED69E57A-E38C-42E8-895C-B2844A1655C6/0/GlobalFilingManual20110419.pdf

Really we also feel lack of functionality (flexibility) of XDTO. We had to stop using it because we have not find a solution to implement what we needed.
Please listen to us and add flexibility to prefixes.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.