Usar parámetros de fórmula
Los fragmentos de código que aparecen más abajo muestran cómo usar parámetros de fórmulas XBRL en varios lenguajes de programación. Para más información, consulte la descripción de la interfaz XBRL de una API de servidor.
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" } );
|
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"})
|
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" });
|
Como la biblioteca de tipos de RaptorXML no se puede cargar con lenguajes de scripting y el tipo XBRLFormulaParameters no existe, el usuario de VBScript debe declarar una clase en su programa, en lugar de usar objetos XBRL.FormulaParam. La clase debe tener dos propiedades públicas: ParamName y ParamValue (al igual que XBRL.FormulaParam). La clase debería tener un constructor que tome el tipo y el valor (porque esto facilita su uso). De lo contrario, es necesario crear el objeto y definir sus miembros. Para más información, consulte la descripción de la interfaz XBRL de una API de servidor.
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
|
Como la biblioteca de tipos de RaptorXML no se puede cargar con lenguajes de scripting y el tipo XBRLFormulaParameters no existe, el usuario de JScript debe declarar clases función en su programa que almacene el par valor/tipo, en lugar de usar objetos XBRL.FormulaParam. El nombre de los miembros debe ser ParamType y ParamValue. Para más información, consulte la descripción de la interfaz XBRL de una API de servidor.
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()
|