{"id":1982,"date":"2014-06-15T13:56:56","date_gmt":"2014-06-15T11:56:56","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=1982"},"modified":"2014-06-15T14:20:33","modified_gmt":"2014-06-15T12:20:33","slug":"xslt-marc21-mini-guide","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=1982","title":{"rendered":"XSLT Marc21 Mini guide"},"content":{"rendered":"<p>XSL stands for EXtensible Stylesheet Language, and is a style sheet language for XML documents.<\/p>\n<h2>XSLT = XSL Transformations<\/h2>\n<p>XSLT is the most important part of XSL.<\/p>\n<p>XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML. Normally XSLT does this by transforming each XML element into an (X)HTML element.<\/p>\n<h2>XSLT Uses XPath<\/h2>\n<p>XSLT uses XPath to find information in an XML document. XPath is used to navigate through elements and attributes in XML documents.<\/p>\n<h2>Correct Style Sheet Declaration<\/h2>\n<p>The root element that declares the document to be an XSL style sheet is &lt;xsl:stylesheet&gt; or &lt;xsl:transform&gt;.<\/p>\n<p><b>Note:<\/b> &lt;xsl:stylesheet&gt; and &lt;xsl:transform&gt; are completely synonymous and either can be used!<\/p>\n<p>The correct way to declare an XSL style sheet according to the W3C XSLT Recommendation is:<\/p>\n<div>\n<div>&lt;xsl:stylesheet version=&#8221;1.0&#8243;<br \/>\nxmlns:xsl=&#8221;http:\/\/www.w3.org\/1999\/XSL\/Transform&#8221;&gt;<\/div>\n<\/div>\n<p>or:<\/p>\n<div>\n<div>&lt;xsl:transform version=&#8221;1.0&#8243;<br \/>\nxmlns:xsl=&#8221;http:\/\/www.w3.org\/1999\/XSL\/Transform&#8221;&gt;<\/div>\n<\/div>\n<p>To get access to the XSLT elements, attributes and features we must declare the XSLT namespace at the top of the document.<\/p>\n<h2>Link the XSL Style Sheet to the XML Document<\/h2>\n<p>&nbsp;<\/p>\n<p>Add the XSL style sheet reference to your XML document (&#8220;cdcatalog.xml&#8221;):<\/p>\n<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br \/>\n<strong>&lt;?xml-stylesheet type=&#8221;text\/xsl&#8221; href=&#8221;cdcatalog.xsl&#8221;?&gt;<\/strong><br \/>\n&lt;catalog&gt; &#8230;<\/p>\n<p style=\"text-align: center;\">Some Screen XSLT samples about tables and textual formatting :<br \/>\n<a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt1.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-2000\" alt=\"xslt1\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt1-300x146.jpg\" width=\"300\" height=\"146\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt1-300x146.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt1-1024x499.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt1.jpg 1219w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt2.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1995\" alt=\"xslt2\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt2-300x256.jpg\" width=\"300\" height=\"256\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt2-300x256.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt2.jpg 670w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt3.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1994\" alt=\"xslt3\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt3-300x274.jpg\" width=\"300\" height=\"274\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt3-300x274.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt3.jpg 658w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1993\" alt=\"xslt4\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4-300x270.jpg\" width=\"300\" height=\"270\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4-300x270.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4.jpg 647w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4-sample.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1992\" alt=\"xslt4-sample\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4-sample-300x143.jpg\" width=\"300\" height=\"143\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4-sample-300x143.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4-sample-1024x489.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt4-sample.jpg 1228w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1991\" alt=\"xslt5\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5-290x300.jpg\" width=\"290\" height=\"300\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5-290x300.jpg 290w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5.jpg 542w\" sizes=\"(max-width: 290px) 100vw, 290px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5-sample.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1990\" alt=\"xslt5-sample\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5-sample-300x142.jpg\" width=\"300\" height=\"142\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5-sample-300x142.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5-sample-1024x485.jpg 1024w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt5-sample.jpg 1221w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt6.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1989\" alt=\"xslt6\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt6-300x173.jpg\" width=\"300\" height=\"173\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt6-300x173.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt6.jpg 616w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>Again, We must declare the XSLT namespace at the top of the document like marc norms (<strong>prefix marc instead xsl<\/strong>) below :<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt7.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1988\" alt=\"xslt7\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt7-300x223.jpg\" width=\"300\" height=\"223\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt7-300x223.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt7.jpg 846w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt8.jpg\"><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-1987\" alt=\"xslt8\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt8-300x233.jpg\" width=\"300\" height=\"233\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt8-300x233.jpg 300w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/06\/xslt8.jpg 812w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Useful information about each specific XSL\u00a0 element.<\/strong><\/span><\/p>\n<p>apply-imports : \u00a0\u00a0 Applies a template rule from an imported style sheet<br \/>\napply-templates : \u00a0\u00a0 Applies a template rule to the current element or to the current element&#8217;s child nodes<br \/>\nattribute : \u00a0\u00a0 Adds an attribute<br \/>\nattribute-set : \u00a0\u00a0 Defines a named set of attributes<br \/>\ncall-template \u00a0 :\u00a0 Calls a named template<br \/>\nchoose : \u00a0\u00a0 Used in conjunction with &lt;when&gt; and &lt;otherwise&gt; to express multiple conditional tests<br \/>\ncomment : \u00a0\u00a0 Creates a comment node in the result tree<br \/>\ncopy\u00a0 :\u00a0\u00a0 Creates a copy of the current node (without child nodes and attributes)<br \/>\ncopy-of\u00a0 :\u00a0\u00a0 Creates a copy of the current node (with child nodes and attributes)<br \/>\ndecimal-format\u00a0 :\u00a0\u00a0 Defines the characters and symbols to be used when converting numbers into strings, with the format-number() function<br \/>\nelement : \u00a0\u00a0 Creates an element node in the output document<br \/>\nfallback \u00a0 :\u00a0 Specifies an alternate code to run if the processor does not support an XSLT element<br \/>\nfor-each\u00a0 :\u00a0\u00a0 Loops through each node in a specified node set<br \/>\nif\u00a0 :\u00a0\u00a0 Contains a template that will be applied only if a specified condition is true<br \/>\nimport \u00a0 :\u00a0 Imports the contents of one style sheet into another. Note: An imported style sheet has lower precedence than the importing style sheet<br \/>\ninclude \u00a0 :\u00a0 Includes the contents of one style sheet into another. Note: An included style sheet has the same precedence as the including style sheet<br \/>\nkey \u00a0 :\u00a0 Declares a named key that can be used in the style sheet with the key() function<br \/>\nmessage \u00a0\u00a0 \u00a0Writes a message to the output (used to report errors)<br \/>\nnamespace-alias \u00a0\u00a0 \u00a0Replaces a namespace in the style sheet to a different namespace in the output<br \/>\nnumber \u00a0\u00a0 \u00a0Determines the integer position of the current node and formats a number<br \/>\notherwise \u00a0\u00a0 \u00a0Specifies a default action for the &lt;choose&gt; element<br \/>\noutput \u00a0\u00a0 \u00a0Defines the format of the output document<br \/>\nparam \u00a0\u00a0 \u00a0Declares a local or global parameter<br \/>\npreserve-space \u00a0\u00a0 \u00a0Defines the elements for which white space should be preserved<br \/>\nprocessing-instruction \u00a0\u00a0 \u00a0Writes a processing instruction to the output<br \/>\nsort \u00a0\u00a0 \u00a0Sorts the output<br \/>\nstrip-space \u00a0\u00a0 \u00a0Defines the elements for which white space should be removed<br \/>\nstylesheet \u00a0\u00a0 \u00a0Defines the root element of a style sheet<br \/>\ntemplate \u00a0\u00a0 \u00a0Rules to apply when a specified node is matched<br \/>\ntext \u00a0\u00a0 \u00a0Writes literal text to the output<br \/>\ntransform \u00a0\u00a0 \u00a0Defines the root element of a style sheet<br \/>\nvalue-of \u00a0\u00a0 \u00a0Extracts the value of a selected node<br \/>\nvariable \u00a0\u00a0 \u00a0Declares a local or global variable<br \/>\nwhen \u00a0\u00a0 \u00a0Specifies an action for the &lt;choose&gt; element<br \/>\nwith-param \u00a0\u00a0 \u00a0Defines the value of a parameter to be passed into a template<\/p>\n<p><strong><span style=\"text-decoration: underline;\">In addition, there are the following built-in XSLT functions:<\/span><\/strong><\/p>\n<p>current() \u00a0\u00a0 \u00a0Returns the current node<br \/>\ndocument() \u00a0\u00a0 \u00a0Used to access the nodes in an external XML document<br \/>\nelement-available() \u00a0\u00a0 \u00a0Tests whether the element specified is supported by the XSLT processor<br \/>\nformat-number() \u00a0\u00a0 \u00a0Converts a number into a string<br \/>\nfunction-available() \u00a0\u00a0 \u00a0Tests whether the function specified is supported by the XSLT processor<br \/>\ngenerate-id() \u00a0\u00a0 \u00a0Returns a string value that uniquely identifies a specified node<br \/>\nkey() \u00a0\u00a0 \u00a0Returns a node-set using the index specified by an &lt;xsl:key&gt; element<br \/>\nsystem-property() \u00a0\u00a0 \u00a0Returns the value of the system properties<br \/>\nunparsed-entity-uri() \u00a0\u00a0 \u00a0Returns the URI of an unparsed entity<\/p>\n","protected":false},"excerpt":{"rendered":"<p>XSL stands for EXtensible Stylesheet Language, and is a style sheet language for XML documents. XSLT = XSL Transformations XSLT is the most important part of XSL. XSLT is used to transform an XML&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2848,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[32,295,210,26],"tags":[],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1982"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1982"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1982\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2848"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}