我正在用一个用户实现一个系统,可以在 Items 的集合上生成一个文档。项目包含名称和 ItemTypeId 。用户可以选择应用于某种类型的项目的模板。它存储在组合对象中,其中包含itemTypeId到TemplateId的映射。
因此用于生成文档的XML数据如下所示:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<composition>
<ItemType>
<ItemTypeId>IT1</ItemTypeId>
<TemplateId>T1</TemplateId>
</ItemType>
<ItemType>
<ItemTypeId>IT2</ItemTypeId>
<TemplateId>T3</TemplateId>
</ItemType>
<ItemType>
<ItemTypeId>IT3</ItemTypeId>
<TemplateId>T2</TemplateId>
</ItemType>
<ItemType>
<ItemTypeId>IT4</ItemTypeId>
<TemplateId>T1</TemplateId>
</ItemType>
</composition>
<items>
<item>
<ItemTypeId>IT1</ItemTypeId>
<Name>A</Name>
</item>
<item>
<ItemTypeId>IT2</ItemTypeId>
<Name>B</Name>
</item>
<item>
<ItemTypeId>IT3</ItemTypeId>
<Name>C</Name>
</item>
<item>
<ItemTypeId>IT2</ItemTypeId>
<Name>D</Name>
</item>
</items>
</data>
要生成我想要使用包含4个模板的XSLT的文档。
XSLT:
<xsl:template match="/">
<html>
<body>
<h2>Document</h2>
<xsl:for-each select="/data/items/item">
<xsl:variable name="itemTypeId" select="current()/ItemTypeId" />
<xsl:apply-templates select="current()"/>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="item[/data/composition/ItemType[ItemTypeId = current()/ItemTypeId]/TemplateId='T1']">
<h1>T1</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item[/data/composition/ItemType[ItemTypeId = current()/ItemTypeId]/TemplateId='T2']">
<h1>T2</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item[/data/composition/ItemType[ItemTypeId = current()/ItemTypeId]/TemplateId='T3']">
<h1>T3</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item[/data/composition/ItemType[ItemTypeId = current()/ItemTypeId]/TemplateId='T4']">
<h1>T4</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item">
</xsl:template>
我在匹配模式中使用current()函数来查看合成并查看是否需要应用模板。这在W3Schools的在线XSLT编辑器中完美运行,并生成以下文档:
输出(在W3Schools xslt编辑器上):
文件
T1
项目A类型 IT1T3
项目B,类型IT2T2
项目C 类型为IT3T3
项目D,类型为IT2
但是,当我尝试在.Net应用程序中实现它时,我收到以下错误:
'current()'函数不能用于模式。
在我看来,.NET不允许在匹配模式中使用 current()。有没有人知道解决这个问题的方法?或者有人能指出我逻辑上的缺陷吗?
修改 我使用 System.Xml.Xsl 中的标准.NET方法应用xslt,如下所示:
XElement data = XElement.Parse("xml is entered here");
XElement stylesheet = XElement.Parse("xslt is entered here");
XslCompiledTransform compiledTransform = new XslCompiledTransform();
compiledTransform.Load(stylesheet.CreateReader());
// Create an xml writer to write to the result stream.
using (XmlWriter writer = XmlWriter.Create(result, compiledTransform.OutputSettings))
{
// Apply the transformation.
compiledTransform.Transform(data.CreateReader(), null, writer);
}
// Return the result.
return result;
答案 0 :(得分:1)
您可以使用密钥:
07-06 09:28:21.797 4780-4780/com.example.brian.mapboxdemo W/art: Failed to find OatDexFile for DexFile /data/data/com.example.brian.mapboxdemo/files/instant-run/dex/slice-slice_9-classes.dex ( canonical path /data/data/com.example.brian.mapboxdemo/files/instant-run/dex/slice-slice_9-classes.dex) with checksum 0x69babcd9 in OatFile /data/data/com.example.brian.mapboxdemo/cache/slice-slice_9-classes.dex
07-06 09:28:22.170 4780-4780/com.example.brian.mapboxdemo I/art: Thread[1,tid=4780,WaitingForJniOnLoad,Thread*=0xf4406800,peer=0x742ef970,"main"] recursive attempt to load library "/data/app/com.example.brian.mapboxdemo-1/lib/x86/libmapbox-gl.so"
07-06 09:28:22.170 4780-4780/com.example.brian.mapboxdemo I/art: Thread[1,tid=4780,WaitingForJniOnLoad,Thread*=0xf4406800,peer=0x742ef970,"main"] recursive attempt to load library "/data/app/com.example.brian.mapboxdemo-1/lib/x86/libmapbox-gl.so"
07-06 09:28:22.210 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Telemetry initialize() called...
07-06 09:28:22.214 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Right before Telemetry set enabled in initialized()
07-06 09:28:22.216 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: setTelemetryEnabled(); this.telemetryEnabled = false; telemetryEnabled = true
07-06 09:28:22.216 4780-4780/com.example.brian.mapboxdemo D/MapboxEventManager: Starting Telemetry Up!
07-06 09:28:22.218 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Permissions are good, see if GPS is enabled and if not then setup Ambient.
07-06 09:28:22.221 4780-4780/com.example.brian.mapboxdemo E/MapboxEventManager: Error Trying to load Staging Credentials: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference
07-06 09:28:22.222 4780-4780/com.example.brian.mapboxdemo I/com.mapbox.mapboxsdk.maps.MapView: MapView start Telemetry...
07-06 09:28:22.222 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Telemetry initialize() called...
07-06 09:28:22.222 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: Mapbox Telemetry has already been initialized.
07-06 09:28:22.224 4780-4780/com.example.brian.mapboxdemo D/libEGL: loaded /system/lib/egl/libEGL_emulation.so
07-06 09:28:22.224 4780-4780/com.example.brian.mapboxdemo D/libEGL: loaded /system/lib/egl/libGLESv1_CM_emulation.so
07-06 09:28:22.228 4780-4780/com.example.brian.mapboxdemo D/libEGL: loaded /system/lib/egl/libGLESv2_emulation.so
[ 07-06 09:28:22.233 4780: 4780 D/ ]
HostConnection::get() New Host Connection established 0xeb7259b0, tid 4780
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Vendor: Android
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Version: 1.4 Android META-EGL
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Client APIs: OpenGL_ES
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: EGL Client Extensions: EGL_KHR_get_all_proc_addresses EGL_ANDROID_presentation_time EGL_KHR_image_base EGL_KHR_fence_sync EGL_ANDROID_image_native_buffer
07-06 09:28:22.286 4780-4780/com.example.brian.mapboxdemo W/mbgl: [Android]: In emulator! Enabling hacks :-(
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Found 8 configs
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 0:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 1:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 2:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 3:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 24
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 4:
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.288 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 5:
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 6:
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Config 7:
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Caveat: 12344
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Conformant: 5
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Color: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Red: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Green: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Blue: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Alpha mask: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Depth: 32
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Stencil: 8
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Sample buffers: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: ...Samples: 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Chosen config is 0
07-06 09:28:22.289 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: Chosen window format is 1
07-06 09:28:22.310 4780-4780/com.example.brian.mapboxdemo I/MapboxEventManager: flushEventsQueueImmediately() called...
07-06 09:28:22.312 4780-4780/com.example.brian.mapboxdemo D/MapboxEventManager: turnstile event pushed.
07-06 09:28:22.318 4780-4836/com.example.brian.mapboxdemo D/OpenGLRenderer: Render dirty regions requested: true
07-06 09:28:22.323 4780-4780/com.example.brian.mapboxdemo D/Atlas: Validating map...
07-06 09:28:22.330 4780-4780/com.example.brian.mapboxdemo I/TelemetryService: onCreate() called
07-06 09:28:22.331 4780-4780/com.example.brian.mapboxdemo I/TelemetryService: onStartCommand() called
07-06 09:28:22.351 4780-4836/com.example.brian.mapboxdemo I/OpenGLRenderer: Initialized EGL, version 1.4
[ 07-06 09:28:22.351 4780: 4836 D/ ]
HostConnection::get() New Host Connection established 0xe3d0b710, tid 4836
07-06 09:28:22.398 4780-4836/com.example.brian.mapboxdemo D/OpenGLRenderer: Enabling debug mode 0
07-06 09:28:22.446 4780-4836/com.example.brian.mapboxdemo W/EGL_emulation: eglSurfaceAttrib not implemented
07-06 09:28:22.446 4780-4836/com.example.brian.mapboxdemo W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe3d07ea0, error=EGL_SUCCESS
07-06 09:28:22.535 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Vendor: Google (ATI Technologies Inc.)
07-06 09:28:22.546 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Renderer: Android Emulator OpenGL ES Translator (AMD Radeon R9 200 Series)
07-06 09:28:22.548 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Version: OpenGL ES 2.0 (4.5.13440 Compatibility Profile Context 16.200.1013.0)
07-06 09:28:22.548 4780-4780/com.example.brian.mapboxdemo I/mbgl: [OpenGL]: GL Extensions: GL_EXT_debug_marker GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float GL_OES_texture_npot GL_OES_rgb8_rgba8
07-06 09:28:22.919 4780-4780/com.example.brian.mapboxdemo E/mbgl: [Shader]: Shader failed to compile: Vertex shader failed to compile with the following errors:
ERROR: 0:6: error(#101) Macro redefined: lowp
ERROR: 0:7: error(#101) Macro redefined: mediump
ERROR: 0:8: error(#101) Macro redefined: highp
ERROR: error(#273) 3 compilation errors. No code generated
07-06 09:28:22.919 4780-4780/com.example.brian.mapboxdemo E/mbgl: [Shader]: Vertex shader fill failed to compile: precision highp float;
#ifdef GL_ES
precision highp float;
#else
#define lowp
#define mediump
#define highp
#endif
attribute vec2 a_pos;
uniform mat4 u_matrix;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
}
--------- beginning of crash
07-06 09:28:22.920 4780-4780/com.example.brian.mapboxdemo A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdeadcab1 in tid 4780 (rian.mapboxdemo)`
这看起来好像四个模板更好地简化为单个模板
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="ref" match="data/composition/ItemType" use="ItemTypeId"/>
<xsl:template match="/">
<html>
<body>
<h2>Document</h2>
<xsl:apply-templates select="/data/items/item"/>
</body>
</html>
</xsl:template>
<xsl:template match="item[key('ref', ItemTypeId)/TemplateId='T1']">
<h1>T1</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item[key('ref', ItemTypeId)/TemplateId='T2']">
<h1>T2</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item[key('ref', ItemTypeId)/TemplateId='T3']">
<h1>T3</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item[key('ref', ItemTypeId)/TemplateId='T4']">
<h1>T4</h1>
Item <xsl:value-of select="current()/Name"/>
with type <xsl:value-of select="current()/ItemTypeId"/><br/>
</xsl:template>
<xsl:template match="item">
</xsl:template>
</xsl:stylesheet>
或者你需要切换到像Saxon 9或XmlPrime这样的XSLT 2.0处理器,支持在模式中使用 <xsl:template match="item[key('ref', ItemTypeId)]">
<h1><xsl:value-of select="key('ref', ItemTypeId)/TemplateId"/></h1>
Item <xsl:value-of select="Name"/>
with type <xsl:value-of select="ItemTypeId"/><br/>
</xsl:template>
。