Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Google search


Poll
How big is your Baan-DB (just Data AND Indexes)
0 - 200 GB
18%
200 - 500 GB
26%
500 - 800 GB
3%
800 - 1200 GB
9%
1200 - 1500 GB
12%
1500 - 2000 GB
12%
> 2000 GB
21%
Total votes: 34

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 21st November 2018, 16:02
dhruv_x0's Avatar
dhruv_x0 dhruv_x0 is offline
Member
 
Join Date: Oct 2010
Location: New Delhi
Posts: 85
dhruv_x0 is on a distinguished road
Baan: baan 4,erp ln6 FP2 - DB: MS SQL - OS: Windows XP,Windows 2000
XML File
Baan: ERP LN 6.1 FP10 (Infor ERP 10.4)
C/S: None/Unknown

Hello All,

Need one help in fixing the xml file which i am generating from LN program. Line 1 generated in xml file is below:

<?xml version="1.0"?>

I don't want this line in my xml file, instead of this i need below data. Any idea how to achieve this?

<docsets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:SsproNamespace"
xsi:schemaLocation="urn:SsproNamespace ssdataDXMschema_09.xsd">



Thanks In Advance
Attached Images
File Type: jpg Pic 1.JPG (30.5 KB, 8 views)
File Type: jpg pic2.JPG (38.6 KB, 9 views)

Last edited by dhruv_x0 : 21st November 2018 at 16:30.
Reply With Quote
  #2  
Old 22nd November 2018, 09:10
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,365
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
That tag on the top is generated by default when you write an XML to a file.


To remove it you have two options -



1. Once the file is generated, read the file and remove the first line and save it again.
2. Once you create the first node, write it to a string and then user str.replace$ to remove the part you don't want and then write that string to your file.


e.g.


Code:
long parentnode
long ns
string oldstr(3000)
string newstr(3000)
string toreplace(100)

parentnode = xmlNewNode  ("docsets")
ns = xmlNewNamespace( parentnode, "xsi", "http://www.w3.org/2001/XMLSchema-instance" )
ns = xmlNewNamespace( parentnode, "", "urn:SsproNamespace" )
ns = xmlNewNamespace( parentnode, "schemaLocation", "urn:SsproNamespace ssdataDXMschema_09.xsd" )

xmlWriteToString  (oldstr, parentnode)
oldstr = trim$(oldstr)
toreplace = "<?xml version=" & chr$(34) & "1.0" & chr$(34) & "?>"
newstr = str.replace$(oldstr,toreplace,"")


Here I am generating the first node without the default XML tag by replacing it with a blank space.



See if this helps you.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #3  
Old 22nd November 2018, 16:20
dhruv_x0's Avatar
dhruv_x0 dhruv_x0 is offline
Member
 
Join Date: Oct 2010
Location: New Delhi
Posts: 85
dhruv_x0 is on a distinguished road
Baan: baan 4,erp ln6 FP2 - DB: MS SQL - OS: Windows XP,Windows 2000
Thanks Bhushan for your reply. I tried 2nd option and still getting the default xml tag so now trying the 1st option. Can we achieve something like that reading the first line of a file and replace it with some other string. For doing this i believe we need to create a new file and write first file data to new file with new string as first line.
Reply With Quote
  #4  
Old 22nd November 2018, 20:18
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,365
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Why didn't option 2 worked for you? Once you replace the required line, just put it in a file using seq.puts() instead of xml.write. Do that for all the other tags.

For option one, yes, you can write a small shell/batch script to remove the first line of your XML file. Google it and you will find a lot of threads.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #5  
Old 27th November 2018, 19:58
dhruv_x0's Avatar
dhruv_x0 dhruv_x0 is offline
Member
 
Join Date: Oct 2010
Location: New Delhi
Posts: 85
dhruv_x0 is on a distinguished road
Baan: baan 4,erp ln6 FP2 - DB: MS SQL - OS: Windows XP,Windows 2000
It worked and i am able to remove this first line now. One small issue and just wanted to know if there is standard function to achieve that.

As suggested I am using below query to create the namespace
Quote:
cmfID = xmlNewNode("docsets")
ns = xmlNewNamespace( cmfID, "xsi", "http://www.w3.org/2001/XMLSchema-instance" )
ns = xmlNewNamespace( cmfID, " ", "urn:SsproNamespace" )
ns = xmlNewNamespace( cmfID, "schemaLocation", "urn:SsproNamespace ssdataDXMschema_09.xsd" )
Output from this is below

Quote:
<docsets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:SsproNamespace"
xmlns:schemaLocation="urn:SsproNamespace ssdataDXMschema_09.xsd"
>

In last line instead of "xmlns" marked in blue i need "xsi" to make file readable from another tool . Is there any standard function to achieve that? I noticed xmlns is coming default if we are creating any namespace.

Thank You in Advance.
Reply With Quote
Sponsored Links
  #6  
Old 28th November 2018, 08:09
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 114
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
How about
Code:
cmfID = xmlNewNode("docsets")
ns1 = xmlNewNamespace( cmfID, "xsi", "http://www.w3.org/2001/XMLSchema-instance" )
ns2 = xmlNewNamespace( cmfID, " ", "urn:SsproNamespace" )
ret = xmlSetAttributeNs( cmfID, ns1, "schemaLocation", "urn:SsproNamespace ssdataDXMschema_09.xsd" )
Reply With Quote
  #7  
Old 29th November 2018, 15:37
dhruv_x0's Avatar
dhruv_x0 dhruv_x0 is offline
Member
 
Join Date: Oct 2010
Location: New Delhi
Posts: 85
dhruv_x0 is on a distinguished road
Baan: baan 4,erp ln6 FP2 - DB: MS SQL - OS: Windows XP,Windows 2000
Thank You very much, it worked pretty well. Still got one issue in the namespace which is not letting me read this file.
Below is the code which is i am using for building xml namespace.
Quote:
ns1 = xmlNewNamespace( cmfID, "xsi", "http://www.w3.org/2001/XMLSchema-instance")
ns2 = xmlNewNamespace( cmfID, " ", "urn:SsproNamespace" )
ret = xmlSetAttributeNs( cmfID, ns1, "schemaLocation", "urn:SsproNamespace ssdataDXMschema_09.xsd" )
and i am getting the below output. I am unable to read the file because of the COLON : present after xmlns in line 2 marked in blue. I need to remove the first colon: from line 2. Looked into the xml help functions but couldn't find anything to remove this. Is there any standard function to achieve this.
Quote:
<docsets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:="urn:SsproNamespace"
xsi:schemaLocation="urn:SsproNamespace ssdataDXMschema_09.xsd">
Appreciate all your help on this so far.

Thank You.
Reply With Quote
  #8  
Old 29th November 2018, 17:23
giggty's Avatar
giggty giggty is offline
Senior Member
 
Join Date: May 2017
Posts: 114
giggty is on a distinguished road
Baan: Infor ERP 10.6 - DB: MSSQL Server 2008 R2 - OS: Windows Server 2012
Like this?
Code:

ns1 = xmlNewNamespace( cmfID, "xsi", "http://www.w3.org/2001/XMLSchema-instance")
xmlSetAttribute( cmfID, "xmlns", "urn:SsproNamespace" )
ret = xmlSetAttributeNs( cmfID, ns1, "schemaLocation", "urn:SsproNamespace ssdataDXMschema_09.xsd" )
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Question mr_suleyman Tools Development 37 11th November 2016 09:14
Return value -2 on seq.open mmtmalone Tools Development 2 8th January 2014 23:03
bshell received SIGTERM manojsharma Tools Development 11 5th June 2008 10:22
Problems reading XML file. baanware Tools Development 4 2nd November 2004 13:37
Redirect Print to xml file prajesh Tools Administration & Installation 5 8th July 2002 16:56


All times are GMT +2. The time now is 00:54.


©2001-2018 - Baanboard.com - Baanforums.com