XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 29 Sep 2005 07:10 AM
Hello,
I hope anybody can help me.
Im new in Stylus Studio and I have a difficult problem. At least for me.
I have an XML sheet exported from an Account program.
I have a node GLAccount and a node Costcenter. The number in the node GLAccount has to be changed, but in what that depends of two other tables.
Suppose the GL Account = 4000.
I look in table1 and find that GLAccount 4000 has a code of 220. In that case I know I have to do something, otherwise I can go to the next record.
If its code 220 I have to look in the main XML sheet to the costcenter. Suppose this is costcenter 15, than I have to look in table2 for the code belonging to costcenter 15. This code I concatenate to the GLAccount (4000).
I have linked the exported XML sheet to an Schema. Because in that case I got an xsl file and I suppose that I have to use the When clause in xsl in order to handle this problem. But maybe Im wrong and I can change the values in an XML file.

Please can anybody give me a help.

Thank you very much.

Yvonne

Postnext
Ivan PedruzziSubject: Link multiple files
Author: Ivan Pedruzzi
Date: 29 Sep 2005 08:35 AM
Could you post a very small samples of your xml files?


Ivan Pedruzzi
Stylus Studio Team

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 29 Sep 2005 03:22 PM
Thank you for your help.
Here are the three files. One is a word document. The XML is so big that I just copied a part of it.

Kind regards,

Yvonne de Vries


UnknownFinEntries.doc
Main xml document

UnknownGrootboekVerdichtingscode.xml


UnknownVerdicode_USGAAP_NL.xml

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 04 Oct 2005 04:07 AM
Dear Ivan,

Do you think you have an answer on my question? Do I have to give additional information?

Thanks again.

Yvonne

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 04 Oct 2005 11:52 AM
Can you please provide us with additional info ?

1) Which file do I have to use to find GLAccount value? The only file where I was able to find GLAccount node is FinEntries.doc, but it does not seem to be the right one.
Do I have to look in GrootboekVerdichtingscode.xml to get the values ?

2) Assuming the GLAccount value will be obtained from GrootboekVerdichtingscode.xml <Grtbk.>4000</Grtbk.>, and assuming the code can be obtained from the same file from <Verd.>220</Verd.> element, how will we link 4000 value with the cost center ? If we have to look into the FinEntries.doc to find costcenter
a) how will we select proper GLAccount ?
b)
<GLAccount code=" 1010" type="B" side="D">
<Description>CASH FOREIGN CURRENCY</Description>
</GLAccount>
is code attribute contains conscenter ?

3) Do we have to look for the string to concatinate in Verdicode_USGAAP_NL.xml ? if so,
<Kostenplaats>9</Kostenplaats> - is it a costcenter code ?
<USGAAPcode>5</USGAAPcode> - is it a string to concatinate ?


Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 04 Oct 2005 03:01 PM
FinEntry.doc is actually a very big xml file. This file is exported from our accounting program. I just copied / pasted a part of the whole file into a word document.
In FinEntry.doc there is an Element named GLAccount with an attribute code.
If this code is a value in the table GrootboekVerdichtingscode.xml then I have to look in the
FinEntry.xml to the Costcenter element attribute: code (in the same FinEntryLine ofcourse). If I found the Costcenter, I must look in the Verdicode_USGAAP_NL.xml to the USGAAPCode belonging to that Costcenter. This code I must concatenate with the GLAccount code and write it back to the GLAccount code.
I hope this explanation is clear enough. I tried a lot in Stylus Studio, but until now without success.
Thanks for your help. Its very much appreciated.

Yvonne de Vries


UnknownFinEntry.doc

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 04 Oct 2005 05:55 PM
Take a look at the following XQuery. I hope it will do what you want.
declare function local:ConcatAccount($account, $match as xs:integer) as xs:string
{
(:We will perform transformation only in case Verd. = 220 :)
if($match eq 220) then
(: Let's try to find a code attribute for the GLAccount element in the main xml :)
(: The code attribute value must match with the value extracted from "Grtbk." :)
(: This predicate does comparation : '[number(@code) eq number($account)]' :)
let $code := doc("Main.xml")/FinEntries/FinEntry/FinEntryLine/GLAccount[number(@code) eq number($account)]/@code
return
(: check if we've found matching code :)
if(count($code) eq 1) then
(: let's get costcenter from the same record :)
let $costcenter := string($code/../../Costcenter/@code)
return
(: check that we've found conscenter :)
if(count($costcenter) eq 1) then
(: let's search for addition to the Grtbk. using conscenter in our 3-d file :)
(: we have to find a row with 'Kostenplaats' equal to costcenter we've extracted :)
let $addon := doc("Verdicode_USGAAP_NL.xml")/document/row/Kostenplaats[number(.) eq number($costcenter)]
return
(: if addition found concatinate it with original value of "Grtbk." :)
if(count($addon) eq 1) then concat(concat($account, "-"), $addon/../USGAAPcode)
else string($account)
else string($account)
else string($account)
else string($account)
};


<document>
{
for $x in /document/row
return <row><Grtbk.>{ local:ConcatAccount($x/Grtbk., $x/Verd.) }</Grtbk.>{ $x/Verd. }</row>
}
</document>

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 09 Oct 2005 03:31 AM
Thank you for your code. But where must I do the function call? I have tried it in
GLAccount under
<xsl:attribute name="code">
<xsl:value-of select="GLAccount/@code"/>

and I wrote the function after
</xsl:template>

Must I declare
<xsl:script language="JavaScript">?

If there is additional information I can read, please let me know. It's not well documented in the User guide. At least I can't find it.

Thanks for your respond.

Kind regards,

Yvonne

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 09 Oct 2005 11:35 AM
Create new XQuery document in StylusStudio. Specify input file in the scenario. Paste posted code into this new document. Run it.

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 10 Oct 2005 04:55 PM
Thank you. It works perfect. But, I have to make the call from the main.xml in stead of from the GrootboekVerdichtingscode.xml. Code is an attribute. Can I use this sentence in the calling code:
<FinEntries>
{
for $x in /FinEntries/FinEntry/FinEntryLine/GLAccount/code
return <FinEntries><FinEntry><FinEntryLine><GLAccount><code>{ local:ConcatAccount($x/code) }</GLAccount><</FinEntryLine></FinEntry>
}
</FinEntries>

I have to change the value of the attribute code in the main.xml and not the value of the element code value in GrootboekVerdichtingscode.xml. Does that change anything in the code?

Thank you very much for your help.

Kind regards,

Yvonne de Vries

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 11 Oct 2005 03:22 PM
Yes, the code will change. You'll have to walk on your "Main.xml" copying everything except account to the output. local:ConcatAccount
function will change. It will get just an account number as a parameter
and you will have to extract "match" from GrootboekVerdichtingscode.xml.
Of cause you will have to search for the account and code in GrootboekVerdichtingscode.xml instead of main.xml.

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 11 Oct 2005 06:10 PM
Thank you for your answer.

I wrote this code (the function is empty for the moment), but I keep having error messages. Can you please tell me what is wrong. I use the mapper, but the moment I want to call the function, I get error messages.

declare function local:ConcatCode($code as xs:integer) as xs:string
{
return
};

<FinEntries>
<FinEntry>
<FinEntryLine>
<GLAccount>
}
for $x in /FinEntries/FinEntry/FinEntryLine/GLAccount/@code
return <FinEntry><FinEntryLine><GLAccount>{local:ConcatCode($x/@Code)}
}
</GLAccount>
</FinEntryLine>
</FinEntry>
</FinEntries>


Thank you very much. Can I find somewhere documentation about this, because I can not find it in the Stylus Studio user Guide.

Yvonne de Vries

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 11 Oct 2005 10:31 PM
Take a look at those tutorials:


http://www.w3schools.com/xquery/
http://www.brics.dk/~amoeller/XML/querying/

as for error, you can not just have return in a function - it is not valid FLWOR expression (FLWOR is For-Let-Where-Order-Return)

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 12 Oct 2005 03:51 AM
No, I understand that the function just have a return, but I don't know if the calling of the function is right. That was the question.

Thank you

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 12 Oct 2005 08:00 AM
Function can not have just return - this is syntax error. Here is the correct syntax:

declare function local:ConcatCode($code as xs:integer) as xs:string {
let $x:= ""
return $x
};

<FinEntries>
{
for $x in /FinEntries/FinEntry/FinEntryLine/GLAccount/@code
return <FinEntry><FinEntryLine><GLAccount>{local:ConcatCode($x/@Code)}</GLAccount></FinEntryLine></FinEntry>

}
</FinEntries>

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 12 Oct 2005 08:52 AM
This is the error I get with this code


UnknownDoc3.doc

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 12 Oct 2005 09:58 AM
declare function local:ConcatCode($code as xs:integer) as xs:string {
let $x:= xs:string($code)
return $x
};

<FinEntries>
{
for $x in /FinEntries/FinEntry/FinEntryLine/GLAccount
return <FinEntry><FinEntryLine><GLAccount>{ local:ConcatCode(xs:integer(normalize-space($x/@code))) }</GLAccount></FinEntryLine></FinEntry>
}
</FinEntries>

Postnext
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 18 Oct 2005 08:35 AM
Thank you very much about all your help. I have written all the functions I need and it works great. If you want to view my solution, please let me know and I will post them here on the network.

Thanks again.

Kind regards,

Yvonne de Vries

Postnext
(Deleted User) Subject: Link multiple files
Author: (Deleted User)
Date: 18 Oct 2005 12:33 PM
It will be great if you'll post your solution here! Probably it will help someone working on similiar task.

Posttop
Yvonne de VriesSubject: Link multiple files
Author: Yvonne de Vries
Date: 03 Nov 2005 02:01 AM
My solution


Unknownconcat_accounts.xsl

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.