关于在xslt中创建数据透视表的问题 [英] Question about create pivot table in xslt

查看:58
本文介绍了关于在xslt中创建数据透视表的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个xml文件,这里是示例部分:

<?xml version =" 1.0" encoding =" UTF-8"?>

< ProducsList>

< Product id =" 1">

< SpecList>

< Spec>

< SpecLabel>高度< / SpecLabel>

< SpecValue> 10< / SpecValue>

< SpecCat> Dimension< / SpecCat>

< / Spec>

< Spec>

< SpecLabel>宽度< / SpecLabel>

< SpecValue> 6< / SpecValue>

< SpecCat>尺寸< / SpecCat>

< / Spec>

<规格>

< SpecLabel>重量< / SpecLabel>

< SpecValue> 20.5< / SpecValue>

< SpecCat> Weigth< / SpecCat>

< / Spec>

< / SpecList>

< / Prodcut>

< Product id =" 2">

< SpecList>

< Spec>

< SpecLabel>高度< / SpecLabel>

< SpecValue> 8< / SpecValue>

< SpecCat> Dimension< / SpecCat>

< / Spec>

< Spec>

< SpecLabel>宽度< / SpecLabel>

< SpecValue> 5< / SpecValue>

< SpecCat>尺寸< / SpecCat>

< /规格>

<规格>

< SpecLabel>重量< / SpecLabel>

< SpecValue> 18< / SpecValue>

< SpecCat> Weigth< / SpecCat>

< / Spec>

< / SpecList>

< ; / Prodcut>

< Product id =" 3">

< SpecList>

< Spec>

< SpecLabel>高度< / SpecLabel>

< SpecValue> 5< / SpecValue>

< SpecCat>尺寸< / SpecCat>

< / Spec>

< Spec>

< SpecLabel>宽度< / SpecLabel>

< SpecValue> 2< / SpecValue>

< SpecCat>尺寸< / SpecCat>

< / Spec >

< Spec>

< SpecLabel>重量< / SpecLabel>

< SpecValue> 10< / SpecValue>

< SpecCat> Weigth< / SpecCat>

< / Spec>

< / SpecList>

< ; / prodcut>

< / ProductsList>


我需要创建一个基于该xml文件的表格:


-------------------------------------------- --------

标签产品1产品2产品3

------------------- ---------------------------------

身高10 8 5

宽度6 5 2

重量20.5 18 10


我完全失去了,我不知道如何制作那张桌子。任何人都有这个想法吗?非常感谢。


SpecList中有多少Spec未知。


感谢您的帮助。

I have a xml file, here is sample part:
<?xml version="1.0" encoding="UTF-8"?>
<ProducsList>
<Product id="1">
<SpecList>
<Spec>
<SpecLabel>Height</SpecLabel>
<SpecValue>10</SpecValue>
<SpecCat>Dimension</SpecCat>
</Spec>
<Spec>
<SpecLabel>Width</SpecLabel>
<SpecValue>6</SpecValue>
<SpecCat>Dimension</SpecCat>
</Spec>
<Spec>
<SpecLabel>Weight</SpecLabel>
<SpecValue>20.5</SpecValue>
<SpecCat>Weigth</SpecCat>
</Spec>
</SpecList>
</Prodcut>
<Product id="2">
<SpecList>
<Spec>
<SpecLabel>Height</SpecLabel>
<SpecValue>8</SpecValue>
<SpecCat>Dimension</SpecCat>
</Spec>
<Spec>
<SpecLabel>Width</SpecLabel>
<SpecValue>5</SpecValue>
<SpecCat>Dimension</SpecCat>
</Spec>
<Spec>
<SpecLabel>Weight</SpecLabel>
<SpecValue>18</SpecValue>
<SpecCat>Weigth</SpecCat>
</Spec>
</SpecList>
</Prodcut>
<Product id="3">
<SpecList>
<Spec>
<SpecLabel>Height</SpecLabel>
<SpecValue>5</SpecValue>
<SpecCat>Dimension</SpecCat>
</Spec>
<Spec>
<SpecLabel>Width</SpecLabel>
<SpecValue>2</SpecValue>
<SpecCat>Dimension</SpecCat>
</Spec>
<Spec>
<SpecLabel>Weight</SpecLabel>
<SpecValue>10</SpecValue>
<SpecCat>Weigth</SpecCat>
</Spec>
</SpecList>
</Prodcut>
</ProductsList>

I need to create a table look like that based on that xml file:

----------------------------------------------------
Label Product 1 product 2 product 3
----------------------------------------------------
Height 10 8 5
Width 6 5 2
Weight 20.5 18 10

I am totally losed, I don''t know how to create that table. any one has
any idea about that? thank you very much.

Also how many Spec in SpecList is unkown.

Thanks for the help.

推荐答案

Lee写道:
Lee wrote:

我完全失去了,我不知道怎么做创建该表。任何人都有这个想法吗?非常感谢你。
I am totally losed, I don''t know how to create that table. any one has
any idea about that? thank you very much.



将其细分为部分。用英语表达 - 或用任何语言表达

你最舒服 - 然后用它作为指导来写作XSLT的



1)选择一行表格。你如何检索该行所需的所有值

? (提示:你需要使用一个谓词。)你想要什么

来围绕这些值,以便在那一行显示它们? (如果

你正在制作一个HTML表格,那将是< tdelements。)这条线必须被包围以使它显示为一个线? (如果

你正在制作HTML,那将是一个< trelement。)


2)重复表中的其他行。


3)为了显示

表,你需要围绕线条做什么? (如果你正在制作HTML,那将是< tableelement。)


-

()ASCII Ribbon Campaign | Joe Kesselman

/ \标记HTML电子邮件! |系统architexture和动态诗歌

Break it down into parts. Express it in English -- or whatever language
you''re most comfortable in -- and then use that as a guide to writing
the XSLT.

1) Pick one line of the table. How do you retrieve all the values needed
for that line? (Hint: You''ll need to use a predicate.) What do you want
to surround those values with in order to display them in that line? (If
you''re producing an HTML table, that would be <tdelements.) What does
the line have to be surrounded with to make it display as a line? (If
you''re producing HTML, that would be a <trelement.)

2) Repeat for the other lines of the table.

3) What do you need to surround the lines with in order to display the
table? (If you''re producing HTML, that would be a <tableelement.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry


Joe,


非常感谢您的回复。我对xslt很新,所以我不太了解你的意思。你有任何样品代码吗?

再次感谢。


5月31日下午4:44,Joe Kesselman< keshlam-nos .. 。@ comcast.netwrote:
Joe,

Thanks a lot for your reply. I am pretty new to xslt, so I don''t quite
understand what you mean. do you have any sample codes for that?
Thanks again.

On May 31, 4:44 pm, Joe Kesselman <keshlam-nos...@comcast.netwrote:

Lee写道:
Lee wrote:

我完全失去了,我不是''我知道如何创建该表。任何人都有这个想法吗?非常感谢你。
I am totally losed, I don''t know how to create that table. any one has
any idea about that? thank you very much.



将其细分为部分。用英语表达 - 或用任何语言表达

你最舒服 - 然后用它作为指导来写作XSLT的



1)选择一行表格。你如何检索该行所需的所有值

? (提示:你需要使用一个谓词。)你想要什么

来围绕这些值,以便在那一行显示它们? (如果

你正在制作一个HTML表格,那将是< tdelements。)这条线必须被包围以使它显示为一个线? (如果

你正在制作HTML,那将是一个< trelement。)


2)重复表中的其他行。


3)为了显示

表,你需要围绕线条做什么? (如果你正在制作HTML,那将是< tableelement。)


-

()ASCII Ribbon Campaign | Joe Kesselman

/ \标记HTML电子邮件! |系统architexture和kinetic诗歌


Break it down into parts. Express it in English -- or whatever language
you''re most comfortable in -- and then use that as a guide to writing
the XSLT.

1) Pick one line of the table. How do you retrieve all the values needed
for that line? (Hint: You''ll need to use a predicate.) What do you want
to surround those values with in order to display them in that line? (If
you''re producing an HTML table, that would be <tdelements.) What does
the line have to be surrounded with to make it display as a line? (If
you''re producing HTML, that would be a <trelement.)

2) Repeat for the other lines of the table.

3) What do you need to surround the lines with in order to display the
table? (If you''re producing HTML, that would be a <tableelement.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry



Lee写道:
Lee wrote:

非常感谢期待你的答复。我对xslt很新,所以我不太了解你的意思。你有任何样品代码吗?
Thanks a lot for your reply. I am pretty new to xslt, so I don''t quite
understand what you mean. do you have any sample codes for that?



如果你问一般问题,听起来你真的需要通过阅读一些XSLT教程来开始。请参阅我的5/29帖子到

使用xslt转换xhtml线程列表的好地方看看

的信息。特别是,IBM的网站有很多很好的教程和

文章,而且XSLT FAQ网站有很多值得研究的例子。


参见 http://www.catb.org/~esr/faqs/ smart-questions.html - 我很确定

你并不打算这样做,但是你的问题看起来完全像

"请为我做我的家庭作业。


-

()ASCII Ribbon Campaign | Joe Kesselman

/ \标记HTML电子邮件! |系统架构和动态诗歌

If you''re asking that general a question, it sounds like you really need
to start by reading some XSLT tutorials. See my 5/29 post to the
"Transforming xhtml with xslt" thread for a list of good places to look
for information. In particular, IBM''s site has many good tutorials and
articles, and the XSLT FAQ website has many examples worth studying.

See also http://www.catb.org/~esr/faqs/smart-questions.html -- I''m sure
you didn''t intend it, but your question reads entirely too much like
"please do my homework assignment for me."

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry


这篇关于关于在xslt中创建数据透视表的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆