为Crystal报表使用XML数据集 [英] Using XML datasets for a Crystal Report
问题描述
我们有这个XML模式:
We have this XML schema:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Log">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="LogEntry" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="Time" type="xs:dateTime" />
<xs:element name="StringRef" type="xs:string" />
<xs:element name="Parameters" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="Parameter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
,我们要创建一个如下所示的Crysal报表:
and we want to create a Crysal Report that looks like this:
<Time> <Parameter:Name == Text> <Parameter:Name == Param1> <Parameter:Name == Param2>
其中报告的每一行都是一个LogEntry。显示的LogEntry在StringRef参数上进行过滤。因此,给定以下XML:
where each line of the report is one LogEntry. The LogEntry's that are displayed are filitered on the StringRef parameter. So, given the following XML:
<Log>
<LogEntry>
<Time>2009-06-15T11:55:04</Time>
<StringRef>Type1</StringRef>
<Parameters>
<Parameter>
<Name>Text</Name>
<Value>Message1</Value>
</Parameter>
<Parameter>
<Name>Param1</Name>
<Value>1</Value>
</Parameter>
<Parameter>
<Name>Param2</Name>
<Value>2</Value>
</Parameter>
</Parameters>
</LogEntry>
<LogEntry>
<Time>2009-06-15T11:55:05</Time>
<StringRef>Type2</StringRef>
<Parameters>
<Parameter>
<Name>Text</Name>
<Value>Message2</Value>
</Parameter>
<Parameter>
<Name>Param1</Name>
<Value>1</Value>
</Parameter>
<Parameter>
<Name>Param2</Name>
<Value>2</Value>
</Parameter>
</Parameters>
</LogEntry>
<LogEntry>
<Time>2009-06-15T11:55:06</Time>
<StringRef>Type3</StringRef>
<Parameters>
<Parameter>
<Name>Text</Name>
<Value>Message3</Value>
</Parameter>
<Parameter>
<Name>Param1</Name>
<Value>1</Value>
</Parameter>
<Parameter>
<Name>Param2</Name>
<Value>2</Value>
</Parameter>
</Parameters>
</LogEntry>
</Log>
并筛选:
StringRef == Type1 or StringRef == Type3
这个:
2009-06-15T11:55:04 Message1 1 2
2009-06-15T11:55:06 Message3 1 2
我的问题是这可以使用水晶报表吗?如果可以,有关如何做的一些信息将是有帮助的。
My question is this: can this be done using Crystal Reports? If it can, some information on how to do it would be helpful.
注意 - 上面已经匿名化一些,所以我在寻找如何做,而不是一个具体的答案,虽然这将是有用的例子。我们被负责实施本报告的人告知,上述是不可能的,但我认为这应该是可能的。可以说这是不可能的,这只是对我来说意味着更多的工作: - (
Notes - the above has been anonymised somewhat so I'm looking for how to do it rather than a specific answer, although that will be useful as an example. We've been told by the person responsible for implementing this report that the above is not possible, however, I feel that this should be possible. It's OK to say it's impossible, it's just means more work for me :-(
干杯,
Skizz
推荐答案
是的,Crystal可以轻松处理xml数据源,但是你必须意识到数据将被表示为一个表。只要将数据源设置为xml文档,并将所有的字段放在细节部分,看看我的意思,我猜想有一个LogEntry,Parameter和Parameters表。
Yes, Crystal can easily handle an xml datasource. However, you have to realize that the data will be represented as a table. Just set the datasource to the xml doc and put all the fields in the details section to see what I mean. I'd guess there'd be a LogEntry, Parameter, and Parameters tables.
要将参数连接到一行,您可以使用共享stringvar,如下所示...
To concat the parameters into one line you can use a shared stringvar like so...
Group通过LogEntry_Id字段创建这3个公式对象...
Group By the LogEntry_Id field then create these 3 formula objects...
reset_var
reset_var
shared stringvar params;
whileprintingrecords;
params := '';
concat_var
concat_var
shared stringvar params;
whileprintingrecords;
params := params + iif(length(params) = 0, "", " ") + {Parameter.Value};
show_var
shared stringvar params;
whileprintingrecords;
params;
将reset_var拖到组头(抑制组头)。这将重置每个LogEntry上的var。将concat_var拖到详细信息部分(抑制详细信息部分)。这将构建param字符串。然后将show_var拖到组页脚以显示参数。
Drag reset_var to the group header (suppress the group header). This will reset the var on each LogEntry. Drag concat_var to the details section(suppress the details section). This will build the param string. Then drag show_var to the group footer to display the params.
这篇关于为Crystal报表使用XML数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!