Using Formula Parameters

www.altova.com Expand/Collapse All Print this Topic Previous Page Up One Level Next page

Home >  Additional Information > XBRL Formula Parameters >

Using Formula Parameters

The example listings below shows how XBRL formula parameters can be used in various programming languages. For more information, see the description of the Server API's XBRL interface.

 

Java

RaptorXMLFactory rxml = RaptorXML.getFactory();

 XBRL xbrl = rxml.getXBRL();

 

 xbrl.addFormulaParameter( "ns1:string", "ns1:Param1", "ns1:theqname" );

 xbrl.addFormulaParameterNamespace( "ns1", "www.www.www" );

 

 // The parameter is an array of dates

 xbrl.addFormulaArrayParameter( "", "startDates", new Object[]{ new FormulaParam( "xs:date", "2010-01-01" ), new FormulaParam( "xs:date", "2012-01-01" ) } );

 

 // The parameter is an array of figs

 xbrl.addFormulaArrayParameter( "ns1:figs", "startFigs", new Object[]{ "fig1", "fig2", "fig3" } );

 

 // The parameter is an array of figs, dates and raisins (rather wild example)

 xbrl.addFormulaArrayParameter( "ns1:figs", "startDryFruit", new Object[]{ "fig1", "fig2", new FormulaParam( "xs:date", "2010-01-01" ), new FormulaParam( "ns1:raisin", "dried grape" ), "fig3" } );

 

VB.NET

Dim objRaptor As New Server()

  Dim objXBRL As XBRL

   objXBRL = objRaptor.GetXBRL()

 

   objXBRL.AddFormulaParameter("ns1:string", "ns1:Param1", "ns1:theqname")

   objXBRL.AddFormulaParameterNamespace("ns1", "www.www.www")

 

  'The parameter is an array of dates

   objXBRL.AddFormulaArrayParameter("", "startDates", {New XBRLFormulaParam With {.ParamType = "xs:date", .ParamValue = "2010-01-01"}, New XBRLFormulaParam With {.ParamType = "xs:date", .ParamValue = "2012-01-01"}})

 

  'The parameter is an array of figs

   objXBRL.AddFormulaArrayParameter("ns1:figs", "startFigs", {"fig1", "fig2", "fig3"})

 

  'The parameter is an array of figs, dates and raisins (rather wild example)

   objXBRL.AddFormulaArrayParameter("ns1:figs", "startDryFruit", {"fig1", "fig2", New XBRLFormulaParam With {.ParamType = "xs:date", .ParamValue = "2010-01-01"}, New XBRLFormulaParam With {.ParamType = "ns1:raisin", .ParamValue = "dried grape"}, "fig3"})

 

C#

Server app = new Server();

  XBRL objXBRL = app.GetXBRL();

 

   objXBRL.AddFormulaParameter("ns1:string", "ns1:Param1", "ns1:theqname");

   objXBRL.AddFormulaParameterNamespace("ns1", "www.www.www");

 

  //The parameter is an array of dates

   objXBRL.AddFormulaArrayParameter("", "startDates", new object[] {new XBRLFormulaParam { ParamType = "xs:date", ParamValue = "2010-01-01"}, new XBRLFormulaParam {ParamType = "xs:date", ParamValue = "2012-01-01"}});

 

  //The parameter is an array of figs

   objXBRL.AddFormulaArrayParameter("ns1:figs", "startFigs", new object[] {"fig1", "fig2", "fig3"});

 

  //The parameter is an array of figs, dates and raisins (rather wild example)

   objXBRL.AddFormulaArrayParameter("ns1:figs", "startDryFruit", new object[] { "fig1", "fig2", new XBRLFormulaParam { ParamType = "xs:date", ParamValue = "2010-01-01" }, new XBRLFormulaParam { ParamType = "ns1:raisin", ParamValue = "dried grape" }, "fig3" });

 

VBScript

Since the Raptor type library cannot be loaded by scripting languages, and because the type XBRLFormulaParameters doesn't exist, the VBScript user, instead of using XBRL.FormulaParam objects, must declare a class in his/her program. The class must have two public properties, ParamName and ParamValue (just as the XBRL.FormulaParam has). The class should have a constructor that takes the type and value, since this simplifies usage; otherwise the object needs to be created and have its members set). For more information, see the description of the Server API's XBRL interface.

 

 

Class MyPair

  Public ParamType

  Public ParamValue

  Public Default Function Init( inType, inValue )

          ParamType = inType

          ParamValue = inValue

          set Init = Me

  End Function

End Class

 

 

Sub Main

  Dim objRaptor

  Set objRaptor = WScript.GetObject( "", "RaptorXML.Server" )

  Dim objXBRL

  Set objXBRL = objRaptor.GetXBRL

 

  Call objXBRL.AddFormulaParameter("ns1:string", "ns1:Param1", "ns1:theqname")

  Call objXBRL.AddFormulaParameterNamespace("ns1", "www.www.www")

 

  'The parameter is an array of dates

  Call objXBRL.AddFormulaArrayParameter("", "startDates", Array( ( New MyPair)( "xs:date", "2010-01-01"), ( New MyPair)( "xs:date", "2012-01-01") ) )

 

  'The parameter is an array of figs

  Call objXBRL.AddFormulaArrayParameter("ns1:figs", "startFigs", Array("fig1", "fig2", "fig3") )

 

  'The parameter is an array of figs, dates and raisins (rather wild example)

  Call objXBRL.AddFormulaArrayParameter("ns1:figs", "startDryFruit", Array("fig1", "fig2", ( New MyPair)("xs:date", "2010-01-01"(, ( New MyPair)("ns1:raisin", "dried grape"), "fig3") )

End Sub

 

Call Main

 

JScript

Since the Raptor type library cannot be loaded by scripting languages, and because the type XBRLFormulaParameters doesn't exist, the JScript user, instead of using XBRL.FormulaParam objects, must declare function-classes in his/her program that holds the type-value pair. Names of members must be ParamType and ParamValue. For more information, see the description of the Server API's XBRL interface.

 

 

function FormulaParam( inType, inValue)

{

  this.ParamType = inType;

  this.ParamValue = inValue;

}

 

function main()

{

  var objRaptor = new ActiveXObject( "RaptorXML.Server" );

  var objXBRL = objRaptor.GetXBRL();

 

   objXBRL.addFormulaParameter( "ns1:string", "ns1:Param1", "ns1:theqname" );

   objXBRL.addFormulaParameter( "xs:string", "Param1", "bla", "www.www.www" );

     

  // The parameter is an array of dates

   objXBRL.addFormulaArrayParameter("", "startDates", [new FormulaParam("xs:date", "2010-01-01"), new FormulaParam("xs:date", "2012-01-01")]);

 

  // The parameter is an array of figs

   objXBRL.addFormulaArrayParameter("ns1:figs", "startFigs", ["fig1", "fig2", "fig3"]);

 

  // The parameter is an array of figs, dates and raisins (rather wild example)

   objXBRL.addFormulaArrayParameter("ns1:figs", "startDryFruit", ["fig1", "fig2", new FormulaParam("xs:date", "2010-01-01"), new FormulaParam("ns1:raisin", "dried grape"), "fig3"]);

}

 

main()

 

 


© 2019 Altova GmbH