R
R
rev23082020-01-14 14:42:03
Java
rev2308, 2020-01-14 14:42:03

Xslt transform xsl:document and randomUUID?

Good day!
The task with the help of xslt is to split xml into the n-th amount of xml. - OK with this.
But in the outgoing xml there is a tag = GUID, which must be generated in xslt .
I use

<xsl:value-of xmlns:uuid="java.util.UUID" select="uuid:randomUUID()"/>.
Separate xslt everything works, but when added to the main xslt (which splits xml ), the generation stops working.
Help!!!
....
<xsl:template match="ns1:ArrDepMessage">
    <xsl:copy>
      <xsl:apply-templates select=".//ns1:GoodsItem"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="ns1:GoodsItem">
    <xsl:if test="(ns1:VeterinaryIndicator = '1') or (ns1:VeterinaryIndicator = 'true') ">
      <chapter href="FOIVRequest{position()}.xml"/>
      <xsl:document href="D:/FOIVRequest{position()}.xml">
        <FOIVRequest DocumentModeID="1009060E" xmlns="urn:customs.ru:Information:SQDocuments:FOIVRequest:5.14.3" xmlns:CategoryCust="urn:customs.ru:Categories:3.0.0" xmlns:cat_ru="urn:customs.ru:CommonAggregateTypes:5.10.0" xmlns:clt_ru="urn:customs.ru:CommonLeafTypes:5.10.0" xmlns:RUScat_ru="urn:customs.ru:RUSCommonAggregateTypes:5.14.3" xmlns:RUSclt_ru="urn:customs.ru:RUSCommonLeafTypes:5.14.3">
          <cat_ru:DocumentID>
            <xsl:value-of xmlns:uuid="java.util.UUID" select="uuid:randomUUID()"/>
          </cat_ru:DocumentID>
          <xsl:for-each select=

....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2020-01-15
kuzmin @sergueik

I tried rev2308 - everything works for me - what am I doing wrong?

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:uuid="java.util.UUID" version="2.0" exclude-result-prefixes="uuid">
  <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
  <xsl:template match="/">
    <xsl:for-each select="//student">
      <xsl:copy-of select="."/>
      <output>
        <xsl:variable name="random" select="uuid:randomUUID()"/>
        <xsl:value-of select="$random"/>
      </output>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

<?xml version="1.0"?>
<class>
  <student no="1">
    <name>Linus</name>
  </student>
  <student no="2">
    <name>Stallman</name>
  </student>
</class>

<?xml version="1.0" encoding="utf-8"?><student no="1">
    <name>Linus</name>
  </student><output>2f5ed0c2-1b90-45ad-9445-42334d62690f</output><student no="2"
>
    <name>Stallman</name>
  </student><output>f4224811-6795-41ee-b4ab-5cb013330aed</output>

guides had to write different
programs because
Saxon does not want to directly
Static error in {uuid:randomUUID()} in expression in xsl:variable/@select on line 
8 column 65 of transform.xsl:
  XPST0017: Cannot find a 0-argument function named Q{java.util.UUID}randomUUID(). Reflexive calls to Java methods are not available under Saxon-HE
Errors were reported during stylesheet compilation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question