This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

How to get the unparsed entity attribute's value from XSLT

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 2.03 KB  |  views: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2.  
  3. <!DOCTYPE document [
  4. <!ELEMENT document (employee)*>
  5. <!ELEMENT employee (lastname, firstname)>
  6. <!ELEMENT lastname (#PCDATA)>
  7. <!ELEMENT firstname (#PCDATA)>
  8. <!NOTATION FOO SYSTEM 'text/xml'>
  9. <!ENTITY ATTACHMENT SYSTEM 'attach.xml' NDATA FOO>
  10. <!ATTLIST employee
  11.        detail ENTITY #IMPLIED>
  12. ]>
  13. <document>
  14.     <employee detail="ATTACHMENT">
  15.         <lastname>Bob</lastname>
  16.         <firstname>Kevin</firstname>
  17.     </employee>
  18. </document>
  19.        
  20. <?xml version="1.0" encoding="UTF-8"?>
  21.  
  22. <name>Bob Kevin</name>
  23.        
  24. <?xml version="1.0"?>
  25.  
  26. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  27. <xsl:output method="xml" indent="yes"/>
  28.  
  29. <xsl:template match="document">
  30. <Document>
  31.         <xsl:apply-templates select="employee"/>
  32. </Document>
  33. </xsl:template>
  34.  
  35. <xsl:template match="employee">
  36. Employee is:  <xsl:value-of select="@detail"/>
  37. </xsl:template>
  38.  
  39. </xsl:stylesheet>
  40.        
  41. java -jar xalan.jar -IN doc.xml -XSL doc.xsl -OUT docout.xml
  42.        
  43. <?xml version="1.0" encoding="UTF-8"?>
  44. <Document>
  45. Employee is:  ATTACHMENT
  46. </Document>
  47.        
  48. <?xml version="1.0" encoding="UTF-8"?>
  49. <Document>
  50. Employee is:  <name>Bob Kevin</name>
  51. </Document>
  52.        
  53. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  54. <xsl:output method="xml" indent="yes"/>
  55.  
  56. <xsl:template match="document">
  57. <Document>
  58.         <xsl:apply-templates select="employee"/>
  59. </Document>
  60. </xsl:template>
  61.  
  62. <xsl:template match="employee">
  63. Employee is:  <xsl:value-of select=
  64. "unparsed-text(unparsed-entity-uri(@detail))"/>
  65. </xsl:template>
  66.  
  67. </xsl:stylesheet>
  68.        
  69. <?xml version="1.0"?>
  70.  
  71. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  72. <xsl:output method="xml" indent="yes"/>
  73.  
  74. <xsl:template match="document">
  75. <Document>
  76.         <xsl:apply-templates select="employee"/>
  77. </Document>
  78. </xsl:template>
  79.  
  80. <xsl:template match="employee">
  81. Employee is: <xsl:copy-of select="document(unparsed-entity-uri(@detail))"/>
  82. </xsl:template>
  83.  
  84. </xsl:stylesheet>
  85.        
  86. <xsl:copy-of select="document(unparsed-entity-uri(@detail))"/>
clone this paste RAW Paste Data