this my xsl code
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.martin-loetzsch.de/DOTML" version="3.0">
<xsl:import href="http://www.martin-loetzsch.de/DOTML/dotml2dot.xsl"/><xsl:param name="quot" as="xs:string">"</xsl:param>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="dotml">
<xsl:for-each select = "Import/Row">
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
</node>
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || items/subMenu[@name="pns"]/url || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='$quot || items/subMenu[@name="pns"]/url || $quot'/>
</xsl:attribute>
</node>
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || items/subMenu[@name="pppk"]/url || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='$quot || items/subMenu[@name="pppk"]/url || $quot'/>
</xsl:attribute>
</node>
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || items/subMenu[@name="ppt"]/url || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='$quot || items/subMenu[@name="ppt"]/url || $quot'/>
</xsl:attribute>
</node>
<edge fontname="Arial" fontsize="9" label="Permit">
<xsl:attribute name="from">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="to">
<xsl:value-of select='$quot || items/subMenu[@name="pns"]/url || $quot'/>
</xsl:attribute>
</edge>
<edge fontname="Arial" fontsize="9" label="Permit">
<xsl:attribute name="from">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="to">
<xsl:value-of select='$quot || items/subMenu[@name="pppk"]/url || $quot'/>
</xsl:attribute>
</edge>
<edge fontname="Arial" fontsize="9" label="Permit">
<xsl:attribute name="from">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="to">
<xsl:value-of select='$quot || items/subMenu[@name="ppt"]/url || $quot'/>
</xsl:attribute>
</edge>
</xsl:for-each>
</xsl:variable>
<xsl:apply-templates select="$dotml/node()"/>
</xsl:template>
</xsl:stylesheet>
I've followed your suggestion by adding <xsl:param name="quot" as="xs:string">"</xsl:param> tag on line 3 in my xsl document above. I've put the tag on every value in my xsl document, to retrieve the value in my xsl document, so that the value becomes a string
and when I run the code an error occurs as below:
C:\Users\rafif\Desktop\saxons>java -jar saxon-he-10.6.jar -xsl:role policy.xsl -s:role-policy.xml -o:policy.txt
Error in xsl:param/@as on line 3 column 113 of role-policy.xsl:
XPST0081 Namespace prefix 'xs' has not been declared
Errors were reported during stylesheet compilation
the question is, where should I put the <xsl:param name="quot" as="xs:string">"</xsl:param>
tag because I've tried to put the tag on line 3, an error occurs
thank you
CodePudding user response:
Well, it seems the stylesheet you use doesn't create the format you want or your other program needs, so ditch that stylesheet and write your own or at least edit it to not create e.g. <dot-filename>graphs/node</dot-filename>
, that is, remove the line having <dot-filename><xsl:value-of select="@file-name"/></dot-filename>
from that code.
You can do that easily for a local copy of the file and <xsl:import href="dotml2dot.xml"/>
that local copy instead of pulling the file from the server.
As for the quotes, it seems you want to convert e.g. <xsl:value-of select='items/subMenu[@name="pns"]/url'/>
to e.g. <xsl:value-of select='$quot || items/subMenu[@name="pns"]/url || $quot'/> after declaring e.g.
<xsl:param name="quot" as="xs:string">"</xsl:param>` as a global parameter.
CodePudding user response:
this is the correct answer...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.martin-loetzsch.de/DOTML" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">
<xsl:import href="dotml2dot.xsl"/>
<xsl:param name="quot" as="xs:string">"</xsl:param>
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="dotml">
<xsl:for-each select = "Import/Row">
<graph file-name="graphs/nice_graph" rankdir="LR">
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='role'/>
</xsl:attribute>
</node>
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || items/subMenu[@name="pns"]/url || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='items/subMenu[@name="pns"]/url'/>
</xsl:attribute>
</node>
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || items/subMenu[@name="pppk"]/url || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='items/subMenu[@name="pppk"]/url'/>
</xsl:attribute>
</node>
<node style="filled" fontsize="16">
<xsl:attribute name="id">
<xsl:value-of select='$quot || items/subMenu[@name="ppt"]/url || $quot'/>
</xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select='items/subMenu[@name="ppt"]/url'/>
</xsl:attribute>
</node>
<edge fontname="Arial" fontsize="9" label="Permit">
<xsl:attribute name="from">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="to">
<xsl:value-of select='$quot || items/subMenu[@name="pns"]/url || $quot'/>
</xsl:attribute>
</edge>
<edge fontname="Arial" fontsize="9" label="Permit">
<xsl:attribute name="from">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="to">
<xsl:value-of select='$quot || items/subMenu[@name="pppk"]/url || $quot'/>
</xsl:attribute>
</edge>
<edge fontname="Arial" fontsize="9" label="Permit">
<xsl:attribute name="from">
<xsl:value-of select='$quot || role || $quot'/>
</xsl:attribute>
<xsl:attribute name="to">
<xsl:value-of select='$quot || items/subMenu[@name="ppt"]/url || $quot'/>
</xsl:attribute>
</edge>
</graph>
</xsl:for-each>
</xsl:variable>
<xsl:apply-templates select="$dotml/node()"/>
</xsl:template>
</xsl:stylesheet>