How to embed css in xml?


Tags: html,css,asp.net,xml

Problem :

I am trying to apply an embedded bar-code font from my css to an xml file. The xml file produces order numbers that I need to display as bar-code.

This document goes directly to email where it then generates a sales' invoice.

This it what generates order numbers:

   <font face="barcode">
                <xsl:value-of select="$OrderInfo/OrderNumber" />

              </font>

I've tried linking my css using both:

<?xml-stylesheet type="text/css" href="App_Themes/Skin_3/style.css" ?>

<link href="App_Themes/Skin_3/style.css" type="text/css" rel="stylesheet"/>

Embedded font in css:

@font-face {
    font-family: barcode;
    src: url(Fonts/IDAutomationHC39M_FREE.otf)  format("truetype");
}

barcode
{
    font-family:barcode; 
     font-size: 26px;
    font-weight:normal;
    }


Solution :

HTML has a link element to link to external style sheets, but not every XML-based format will have such an element. If there is no suitable element, you can still attach external style sheets by means of the xml-stylesheet processing instruction like this:

<?xml-stylesheet href="my-style.css"?>

... rest of document here...

This processing instruction (PI) must come before the first tag of the document. The type="text/css" is not required, but it helps the browser: if it doesn't support CSS, it knows it won't have to download this file.

Just as with the link element of HTML, there can be multiple xml-stylesheet PIs and they can have attributes to set the type, medium and title.

Example

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<?xml-stylesheet type="text/css" href="style.css"?>

Reference ...


    CSS Howto..

    How can I style a JavaFX SplitMenuButton in CSS

    How to make a site have a built in user-friendly editor?

    How to add custom code to specific
  • s in wordpress while building navigation?
  • How can I put a graphic marker next to an item using pure CSS?

    How to reference another selector in css

    How to add stylesheet to toolbar

    How to make a CSS div set auto height to content

    How Do I Use Css To Select A Area Of Code

    How to get this div into the right position

    How do you apply diferent colors from diferent css rules to the same object?

    how to properly use css in jsf?

    How i can add css transition to my Jquery dialog?

    How to add html code into html?

    How to implement Read more / Read less in pure CSS

    How do I remove a specific bullet point within a ul in CSS?

    How to add a border to only percentage of width of element, CSS Trick

    HTML - How do css/javascript files get loaded?

    CSS: How does youtube change its appearance based on screen size?

    How do check the Css properties for an element when pressed in Google Chrome Developer Tools

    Show/Hide Html TR/TD

    How to make a wrapper for HTML, CSS and Javascript Pages in iOS

    How do I add a the bootstrap 'form-control' class to a select using the Simple_Form gem?

    How to use jQuery / CSS to swap out the contents of a DIV onmouseover on list items? [closed]

    How To Create A Responsive Horizontal Layout Using CSS?

    how to auto adjust table td width from the content

    How do you override “-moz-user-select: none;” on a child element?

    How to change pseudo class property?

    how to use javascript to get visited link css styles

    How to have a bold header text?

    How to add a picture to the top of my webpage?