There is a scheme that can change. An xml file that does not fully satisfy this scheme is given. Those. there may be some nodes missing in the schema. It is necessary to convert using xslt this file so that in place of the missing nodes appear empty. To solve the problem once, I decided to write xslt, which according to the scheme creates another xslt, in which the deduction method is called for each node. If a node is found, its parameters are displayed; otherwise, an empty node. All anything, only in the second xslt you need to use xsl:element , and to get it, you need to use <xls:element> in the first xslt)))

Maybe I don’t know something, but I didn’t find the standard way to create xsl:element (stalled while creating content for the new xsl:element ). Tried through <xls:value-of> , also almost succeeded, but stubbornly unwilling to be displayed > and < . Can anyone know how:

  1. Or through xsl:element create xsl:element
  2. Or output > and < .
  • And you can not use the condition? <xsl: if test = "// rootnode / subnode / @ attr"> <! - body -> </ xsl: if> or <xsl: choose> <! - Content: (xsl: when +, xsl: otherwise?) -> </ xsl: choose> - Dex
  • it is possible, even more necessary, only how can it help me in creating an xsl: element, or will it save me from creating it? the scheme can change and in the first xslt I do not know which nodes are registered in the scheme - Ігар Цімошка
  • one
    And how do you make XSL, if you do not know the nodes? - Dex
  • @Dex, I take them from the scheme, it’s written in the question - Ігар Цімошка

1 answer 1

An example of creating xsl:element using xsl:element :

 <xsl:template match="/"> <xsl:element name="xsl:stylesheet"> <xsl:element name="xsl:template"> <xsl:attribute name="match">/</xsl:attribute> <xsl:element name="rootelementofresultdoc">Некий элемент некого документа</xsl:element> </xsl:element> </xsl:element> </xsl:template> 

Angle brackets are rendered using predefined entities &lt; и &gt; &lt; и &gt; :

 <xsl:template name="ltgt"> <xsl:text disable-output-escaping="yes">&lt;xsl:apply-templates /&gt;</xsl:text> </xsl:template> 
  • Your example creates xslt, inside it is xsl: template, and inside the node is <rootelementofresultdoc>, but xsl: element has not been created element "> <xsl: attribute name =" name "select =" 'xsl: template' "/> </ xsl: element> Thanks for the hint with angle brackets - Igar Tsimoshka