数据类型(对于它所支持的内容,它有点通用,但它是针对XSLT/XPath1.0设计的)。关于依赖关系,我不确定您指的是什么,您的原始示例使用Java映射/HashMap,并且可以继续使用它,只有在运行转换之前设置参数的部分需要使用XdmMap.makeMa

数据类型(对于它所支持的内容,它有点通用,但它是针对XSLT/XPath1.0设计的)。关于依赖关系,我不确定您指的是什么,您的原始示例使用Java映射/HashMap,并且可以继续使用它,只有在运行转换之前设置参数的部分需要使用XdmMap.makeMa,java,xml,xslt-2.0,saxon,Java,Xml,Xslt 2.0,Saxon,数据类型(对于它所支持的内容,它有点通用,但它是针对XSLT/XPath1.0设计的)。关于依赖关系,我不确定您指的是什么,您的原始示例使用Java映射/HashMap,并且可以继续使用它,只有在运行转换之前设置参数的部分需要使用XdmMap.makeMap。构造函数new XdmMap(Java.util.Map)仅当java.util.Map是Map时有效。如果您想传入一个Map,那么静态makeMap()方法是一个更好的选择。感谢您的回复!在标准Java API中是否有XdmMap.mak


数据类型(对于它所支持的内容,它有点通用,但它是针对XSLT/XPath1.0设计的)。关于依赖关系,我不确定您指的是什么,您的原始示例使用Java映射/HashMap,并且可以继续使用它,只有在运行转换之前设置参数的部分需要使用
XdmMap.makeMap
。构造函数
new XdmMap(Java.util.Map)
仅当
java.util.Map
Map
时有效。如果您想传入一个
Map
,那么静态
makeMap()
方法是一个更好的选择。感谢您的回复!在标准Java API中是否有XdmMap.makeMap的等价物?我的问题的另一部分是样式表参数是由其他项目发送的,它们必须包含一个Saxon依赖项才能使用XdmMap。如果“标准Java API”是指SUN/Oracle JAXP API,那么答案是否定的,它是面向XSLT 1.0的,XSLT 1.0只支持XSLT/XPath 1.0数据类型(关于它所支持的内容,它有点通用,但它是针对XSLT/XPath 1.0设计的)。关于依赖关系,我不确定您指的是什么,您的原始示例使用Java映射/HashMap,并且可以继续使用它,只有在运行转换之前设置参数的部分需要使用
XdmMap.makeMap
。感谢您的响应。给定的信息对我更有用。感谢您的响应。在中给出队形对我更有用。
   public static void transform(String xmlFile, String xslFile) throws TransformerException,
      TransformerConfigurationException {

   TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer(new StreamSource(new File(xslFile)));
   Map<String,String> mapData = new HashMap<String,String>();
   mapData.put("1", "188 E 6th Street");
   transformer.setParameter("mapData", mapData);
   transformer.transform(new StreamSource(new File(xmlFile)), new StreamResult(System.out));
  }
xmlns:map="http://ns.saxonica.com/map" exclude-result-prefixes="map" >

<xsl:variable name="mapData"/>
<xsl:variable name="addressData" select="map:get($mapData,'1')"/>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
    xmlns:array="http://www.w3.org/2005/xpath-functions/array"
    exclude-result-prefixes="#all"
    expand-text="yes"
    version="3.0">

  <xsl:param name="mapData" as="map(xs:string, xs:string)" select="map { '1' : '188 E 6th Street' }"/>

  <xsl:mode on-no-match="shallow-copy"/>

  <xsl:output method="html" indent="yes" html-version="5"/>

  <xsl:template match="/">
    <html>
      <head>
        <title>.NET XSLT Fiddle Example</title>
      </head>
      <body>
          <h1>XPath 3.1 map example</h1>
          <section>
              <h2>function call syntax</h2>
              <p><code>$mapData('1')</code>: <code>{$mapData('1')}</code></p>
          </section>
          <section>
              <h2>map:get</h2>
              <p><code>map:get($mapData, '1')</code>: <code>{map:get($mapData, '1')}</code></p>
          </section>
          <section>
              <h2><code>?</code> operator</h2>
              <p><code>$mapData?('1')</code>: <code>{$mapData?('1')}</code></p>
          </section>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>
public static void MapExample() throws SaxonApiException {
    Processor processor = new Processor(false);

    XsltExecutable executable = processor.newXsltCompiler().compile(new StreamSource("sheet.xsl"));

    Xslt30Transformer transformer = executable.load30();

    Map<String,String> mapData = new HashMap<String,String>();
    mapData.put("1", "188 E 6th Street");

    HashMap<QName, XdmValue> parameters = new HashMap<>();

    parameters.put(new QName("mapData"), XdmMap.makeMap(mapData));

    transformer.setStylesheetParameters(parameters);

    transformer.applyTemplates(new StreamSource("input1.xml"), transformer.newSerializer(System.out));

    System.out.println();        
}