我是XSLT的新手,所以我真的很感激任何帮助.我在stackoverflow上搜索了很多,尝试应用了几种方法,但都失败了.
我有一个像这样的xml:
<?xml version="1.0" encoding="utf-8"?>
<asset_detail>
<asset id="1" show_type="Movies">
<title><![CDATA[Movie]]></title>
<media_list>
<media id="11" title="" type="trailer">
<version format="m3u8" rel_path="/Content/movie.m3u8"/>
<version format="HLS" rel_path="/movies/movie.m3u8"/>
</media>
</media_list>
</asset>
</asset_detail>
Run Code Online (Sandbox Code Playgroud)
我应该复制整个xml和:
if media_list/media/version/@format = '**HLS**' I need to replace **@rel_path** with
value: **concat**(existing value of **@rel_path****,** **someVariable**
(I'm passing to xsl as a <xsl:param>)
Run Code Online (Sandbox Code Playgroud)
我想我必须使用类似的东西:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:param name="someVariable"/>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="media/version">
<xsl:attribute name="rel_path">
<xsl:choose>
<xsl:when test="./@format = HLS">
<xsl:value-of select="concat(rel_path,$someVariable)">
</xsl:when>
</xsl:choose>
</xsl:attribute>
</xsl:template> …
Run Code Online (Sandbox Code Playgroud) 我有一个关于在Hibernate中使用Restrictions的问题.
我必须创建条件,设置一些限制,然后选择一个最大值为Date字段的记录:
Criteria query = session.createCriteria(Storage.class)
query.add(Restrictions.eq(USER_ID, item.getUserId()));
query.add(Restrictions.eq(ITEM_ID, item.getItemId()));
query.add(Restrictions.lt(PURCHASE_DATE, item.getDate()));
query.setProjection(Projections.max(PURCHASE_DATE));
return query.uniqueResult();
Run Code Online (Sandbox Code Playgroud)
我知道预测不会给我带来最大日期的记录.我应该选择什么方法?
也许我可以为我的查询添加顺序(日期字段上的升序),然后选择第一个结果?
或者你能否建议更优雅的解决方案?
谢谢!