我的XML带有嵌入式富文本格式,看起来大致如下:
13.10.2016 22:42:08.624 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.BundleInstallTask Exception during install of bundle TaskResource(url=jcrinstall:/apps/octoberadvanced/install/advanced.core-1.0-SNAPSHOT.jar, entity=bundle:october.advanced.core, state=INSTALL, attributes=[org.apache.sling.installer.api.tasks.ResourceTransformer=:94:21:, Bundle-SymbolicName=october.advanced.core, Bundle-Version=1.0.0.SNAPSHOT], digest=1476378728376) : Bundle installation rejected by hook.. Retrying later.
org.osgi.framework.BundleException: Bundle installation rejected by hook.
at org.apache.felix.framework.Felix.installBundle(Felix.java:3045)
at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)
at org.apache.sling.installer.core.impl.tasks.BundleInstallTask.execute(BundleInstallTask.java:47)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:735)
at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:249)
at java.lang.Thread.run(Unknown Source)
我正在尝试生成以下HTML:
<?xml version="1.0" encoding="UTF-8"?>
<document>
<richtext>
<pardef/>
<par><run>This is the </run><run>preamble.</run></par>
<pardef list='bullet'/>
<par><run>This is the </run><run>first bullet.</run></par>
<par><run>This is the second </run><run>bullet.</run></par>
</richtext>
</document>
我尝试了以下XSL,但它无法正常工作。我有一种感觉,我需要使用FOLLOWING-SIBLING,但我不确定如何。
<p>This is the preamble.</p>
<ul>
<li>This is the first bullet</li>
<li>This is the second bullet</li>
<ul>
答案 0 :(得分:0)
XSLT 2.0的一种方法和您的设计&#34;:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:key name="key-for-par" match="document/richtext/par" use="generate-id(preceding-sibling::pardef[1])"/>
<xsl:output indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="document/richtext/pardef" />
</xsl:template>
<xsl:template match="pardef[@list = 'bullet']">
<ul>
<xsl:for-each select="key('key-for-par', generate-id(.))">
<li>
<xsl:value-of select="run" separator=""/>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="pardef[not(@list)]">
<p>
<xsl:for-each select="key('key-for-par', generate-id(.))">
<p>
<xsl:value-of select="run" separator=""/>
</p>
</xsl:for-each>
</p>
</xsl:template>
</xsl:stylesheet>
编辑1:改进版本。