我的字体类型存储在xml(Arial,Times New Roman)中,我想在CSS中读取它吗? [英] My font type is stored in xml (Arial,Times New Roman) i want to read it in css it is possible?

查看:88
本文介绍了我的字体类型存储在xml(Arial,Times New Roman)中,我想在CSS中读取它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的要求是我必须将字体类型存储为XML,并且必须在CSS中读取该XML,然后将该字体类型应用于整个HTML页面,该怎么办?
请帮助我


林XMl



< displaydata>
< fonttoshow> Arial


是xslt:---


my requirement is i have to store my font type in XML and i have to read that XML in my CSS and apply that font type to my whole HTML page how can i do?
please help me


Im XMl



<displaydata>
<fonttoshow>Arial


is xslt :---

<?xml version="1.0" encoding="UTF-8">
<xsl:stylesheet version=""1.0"<br" mode="hold" xmlns:xsl="#unknown" />xmlns:xsl="http://www.w3.org/1999/XSL/Transform"">

<xsl:template match="/" xmlns:xsl="#unknown">
 <html>
    <head>
      <style type="text/css">
        body
        {
           	{font-family:<xsl:value-of select="fonttoshow">;}
        }

       </style>
    </head>
  <body></xsl:value-of></xsl:template>

推荐答案

您有一个XML文件,其中包含要在运行时通过XSLT转换转换为HTML的布局数据.
是的,.NET框架简化了这一过程.这是从我网站上的站点地图中摘录的,该站点地图在运行时进行了转换.而不是为搜索引擎手动维护sitemap.xml.

我的XML:
You have an XML file containing layout data that you want transformed into HTML by your XSLT transform at runtime.

Yes, the .NET framework facilitates this. Here is a snipped from the sitemap on my web site that is transformed at run-time. Instead of having a manually maintained sitemap.xml for search engines.

My XML:
<site xmlns="http://redcell.ca/schema/sitemap.xsd" baseurl="http://two-red-cells.com/">
    <page id="services" type="category">
        <page id="3d modelling" type="content" />
        <page id="archiving" type="content" />
        <page id="ipad" type="content" />
        <page id="proofreading" type="content" />
        <page id="web" type="content" />
        <page id="writing" type="content" />
    </page>
    <page id="solutions" type="category">
        <page id="barcoding" type="content" />
        <page id="crowdsourcing" type="content" />
        <page id="intelligent forms" type="content" />
        <page id="nui" type="content" />
        <page id="rfid" type="content" />
        <page id="rtls" type="content" />
        <page id="social mining" type="content" />
        <page id="telemetry" type="content" />
    </page>
    <page id="information" type="category">
        <page id="sitemap" type="content" />
        <page id="contact" type="content" />
        <page id="articles" type="content" />
        <page id="mobile" type="link" />
        <page id="news" type="content" />
        <page id="surplus" type="content" />
        <page id="twitter" type="link" />
    </page>
</site>



我的XSLT:



My XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" xmlns:s="http://redcell.ca/schema/sitemap.xsd">
    <xsl:output method="xml" indent="yes" />

    <xsl:template match="/">
        <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
            <url>
                <loc><xsl:value-of select="s:site/@baseUrl" /></loc>
                <changefreq>daily</changefreq>
                <priority>1.0</priority>
            </url> 
            <xsl:for-each select="//s:page[@type='category']">
                <url>
                    <loc><xsl:value-of select="/s:site/@baseUrl" /><xsl:value-of select="@id" />/</loc>
                    <changefreq>daily</changefreq>
                    <priority>0.75</priority>
                </url> 
            </xsl:for-each>
            <xsl:for-each select="//s:page[@type='content']">
                <url>
                    <loc><xsl:value-of select="/s:site/@baseUrl" /><xsl:value-of select="parent::s:page/@id" />/<xsl:value-of select="@id" /></loc>
                    <changefreq>daily</changefreq>
                    <priority>0.50</priority>
                </url> 
            </xsl:for-each>
        </urlset>
        <xsl:apply-templates select="@* | node()" />
    </xsl:template>
</xsl:stylesheet>



转换代码:



The transformation code:

using System;
using System.IO;
using System.Web.UI;
using System.Xml.Xsl;

/// <summary>
/// Dynamically transforms our XML sitemap into a google sitemap.
/// </summary>
public partial class sitemap : Page
{
    private string _language;
    private const string Stylesheet = "sitemap.xml.xslt";

    protected override void Render(HtmlTextWriter writer)
    {
        // Load the stylesheet into a transformer.
        var xslt = new XslCompiledTransform();
        var path = Path.Combine(Globals.SitePath, @"sitemaps\" + Stylesheet);
        xslt.Load(path);

        // Transform!
        var args = new XsltArgumentList();
        var filename = "sitemap." + _language + ".xml";
        path = Path.Combine(Globals.SitePath, @"sitemaps\" + filename);
        xslt.Transform(path, args, writer);
    }
}


这篇关于我的字体类型存储在xml(Arial,Times New Roman)中,我想在CSS中读取它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆