xslt apply-templates in second level -


I & lt; Panel & gt; Can not wrap tags as separate items at the second level as the expected result is shown in the bellow. Instead, I get all the 1.x element values ​​in XSLT in a node I have written. Please help me

source xml
  & lt; Root & gt; & Lt; Step id = "1" & gt; & Lt; Content & gt; & Lt; Text & gt; 1.0 sample first level step text & lt; / Text & gt; & Lt; / Content & gt; & Lt; Content /> & Lt; Step & gt; & Lt; Content & gt; & Lt; Text & gt; 1.1 sample second level text & lt; / Text & gt; & Lt; / Content & gt; & Lt; / Step & gt; & Lt; Step & gt; & Lt; Content & gt; & Lt; Text & gt; 1.2 SAMPLE SECOND LEVEL TEXT & lt; / Text & gt; & Lt; / Content & gt; & Lt; / Step & gt; & Lt; Step & gt; & Lt; Content & gt; & Lt; Text & gt; 1.3 sample second level text & lt; / Text & gt; & Lt; / Content & gt; & Lt; / Step & gt; & Lt; / Step & gt; & Lt; Step id = "2" & gt; & Lt; Content & gt; & Lt; Text & gt; 2.0 sample first level text lesson & lt; / Text & gt; & Lt; / Content & gt; & Lt; Content /> & Lt; Step & gt; & Lt; Content & gt; & Lt; Text & gt; 2.1 sample second level text & lt; / Text & gt; & Lt; / Content & gt; & Lt; / Step & gt; & Lt; Step & gt; & Lt; Content & gt; & Lt; Text & gt; 2.2 Sample Second Level Phase Text & lt; / Text & gt; & Lt; / Content & gt; & Lt; / Step & gt; & Lt; Step & gt; & Lt; Content & gt; & Lt; Text & gt; 2.3 Sample Second Level Text Text & lt; / Text & gt; & Lt; / Content & gt; & Lt; / Step & gt; & Lt; / Step & gt; & Lt; / Root & gt;  

Expected output

  & lt; Panel & gt; & Lt; Panel & gt; & Lt; Panel & gt; 1.0 Sample first level step text & lt; / Panel & gt; & Lt; Panel & gt; 1.1 sample second level text & lt; / Panel & gt; & Lt; Panel & gt; 1.2 SAMPLE SECOND LEVEL TEXT & lt; / Panel & gt; & Lt; Panel & gt; 1.3 sample second level text & lt; / Panel & gt; & Lt; / Panel & gt; & Lt; Panel & gt; & Lt; Panel & gt; 2.0 sample first level text lesson & lt; / Panel & gt; & Lt; Panel & gt; 2.1 sample second level text & lt; / Panel & gt; & Lt; Panel & gt; 2.2 Sample Second level step text & lt; / Panel & gt; & Lt; Panel & gt; 2.3 sample second level step text & lt; / Panel & gt; & Lt; / Panel & gt; & Lt; / Panel & gt;  

My XSLT

  & lt; Xsl: template match = "/" & gt; & Lt; Panel & gt; & Lt; XSL: implemented-templates / & gt; & Lt; / Panel & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: Template Match = "Root / Phase" & gt; & Lt; Panel & gt; & Lt; Panel & gt; & Lt; Xsl: Apply-Select Template = "Content / Text / Node ()" & gt; & Lt; / Xsl: applied-templates & gt; & Lt; / Panel & gt; & Lt; Panel & gt; & Lt; Xsl: apply-select template = "step / content / text / node ()" & gt; & Lt; / Xsl: applied-templates & gt; & Lt; / Panel & gt; & Lt; / Panel & gt; & Lt; / XSL: Templates & gt;  

The use of the move is // accessor

& lt; Xsl: template match = "/" & gt; & Lt; Panel & gt; & Lt; Xsl: Apply-Select Template = '// Text' / & gt; & Lt; / Panel & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "text" & gt; & Lt; Panel & gt; & Lt; Xsl: apply-select template = "./ node ()" & gt; & Lt; / Xsl: applied-templates & gt; & Lt; / Panel & gt; & Lt; / XSL: Templates & gt; Instead of requiring the formatting instead of

edited , you ask, managing the grouping Add another

  & lt; Xsl: template match = "/" & gt; & Lt; Panel & gt; & Lt; Xsl: Choose Apply-Templates = '/ root / Step' mode = "Basic" /> & Lt; / Panel & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "step" mode = "root" & gt; & Lt ;! - Mode allows to differentiate between other tags 'step' - & gt; & Lt; Panel & gt; & Lt ;! - Now we can convert trees into planar - & gt; & Lt; Xsl: Apply-Select Template = '// Text' / & gt; & Lt; / Panel & gt; & Lt; / XSL: Templates & gt; & Lt; Xsl: template match = "text" & gt; & Lt; Panel & gt; & Lt ;! - Format text from node text - & gt; & Lt; Xsl: Apply-Select Template = "Text ()" & gt; & Lt; / Xsl: applied-templates & gt; & Lt; / Panel & gt; & Lt; / XSL: Templates & gt;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -