在XSL-> XHTML中创建列表并使用图像

时间:2018-10-18 14:17:35

标签: xml xslt xhtml

我有两个字典,这些字典将通过使用XSLT合并到一个输出中。

但是这些单词不会作为列表出现,而是全部排成一行,并且两个“列表”不会像这样并排出现:

瑞典语英语 word1 word2 word2 word3 单词..单词..

此外,我为其创建了xpath的徽标不会显示。

我的CSS文件是否错误,link.xml是否错误或对输出的期望错误?

英语词典(english.xml):

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/contact_selector"
android:minHeight="64dp">

<FrameLayout
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="@+id/guideline"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintTop_toTopOf="@+id/guideline">

    <TextView
        android:id="@+id/image_text"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_marginLeft="16dp"
        android:layout_marginStart="16dp"
        android:background="@drawable/contact_circle"
        android:gravity="center"
        tools:text="A.R" />

</FrameLayout>

<TextView
    android:id="@+id/contact_name"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:ellipsize="end"
    android:maxLines="1"
    android:paddingLeft="16dp"
    android:paddingStart="16dp"
    android:textSize="17sp"
    app:layout_constraintBottom_toTopOf="@+id/guideline"
    app:layout_constraintStart_toEndOf="@+id/image"
    app:layout_constraintEnd_toStartOf="@id/phone_type"
    tools:text="Ali Rezaei asdasdasdasdasdasdasdasd" />

<TextView
    android:id="@+id/phone_number"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:paddingLeft="16dp"
    android:paddingStart="16dp"
    android:textSize="13sp"
    app:layout_constraintStart_toStartOf="@+id/contact_name"
    app:layout_constraintTop_toTopOf="@+id/guideline"
    tools:text="+989121895634" />

<android.support.constraint.Guideline
    android:id="@+id/guideline"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    app:layout_constraintGuide_percent="0.5" />

<TextView
    android:id="@+id/phone_type"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fontFamily="sans-serif-light"
    android:paddingEnd="8dp"
    android:paddingRight="8dp"
    android:textSize="13sp"
    app:layout_constraintBottom_toBottomOf="@+id/guideline"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="@+id/guideline"
    tools:text="Mobile" />

<View
    android:id="@+id/line"
    style="@style/LineStyle"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toEndOf="@+id/image" />

</android.support.constraint.ConstraintLayout>

瑞典语字典(swedish.xml)

<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE thesaurus SYSTEM "dictionary.dtd"> --> 
<?xml-stylesheet type="text/xsl" href="dictionary.xsl"?> 
 <!--Rootelementet kan enbart finnas 1 gang -->
  <dictionary> 
    <language>Engelsk</language>
    <author>
      <firstname>A</firstname>
      <lastname>B</lastname>
    </author>
    <word type="1">House</word> 
    <word type="2">Car</word>
    <word type="3">Fisch</word>
    <word type="4">Cat</word>
    <word type="5">Dog</word>
    <word type="6">Street</word>
    <word type="7">Water</word>
    <word type="8">Stone</word>
    <word type="9">Train</word>
    <word type="10">Color</word>
  </dictionary>

用于链接词典的XML(links.xml)

<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE thesaurus SYSTEM "dictionary.dtd"> --> <!--bortkommenterad så att man ska kunna validera jämte emot xsd schema-->
<?xml-stylesheet type="text/xsl" href="dictionary.xsl"?> <!-- Hamtar xsl styleesheet-->
  <dictionary> 
    <language>Svensk</language>
    <author>
      <firstname>A</firstname>
      <lastname>B</lastname>
    </author>
    <word type="1">Hus</word> 
    <word type="2">Bil</word>
    <word type="3">Fisk</word>
    <word type="4">Katt</word>
    <word type="5">Hund</word>
    <word type="6">Gata</word>
    <word type="7">Vatten</word>
    <word type="8">Sten</word>
    <word type="9">Tåg</word>
    <word type="10">Färg</word>
  </dictionary>

CSS(style.css)

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="dictionary.xslt"?>
    <links>
        <dict>english.xml</dict>
        <dict>svenska.xml</dict>
        <svgLogo name="logo">boksvg.svg</svgLogo>
    </links>

The XSL file (dictionary.xslt)


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/TR/xhtml1/strict">

<xsl:output
   method="xml"
   indent="yes"
   encoding="UTF-8"
/>



<xsl:variable name="dict1">
    <xsl:value-of select="/links/dict[1]" />
</xsl:variable>

<xsl:variable name="dict2">
    <xsl:value-of select="/links/dict[2]" />
</xsl:variable>

<xsl:variable name="logo" select="document(/links/svgLogo[@type='logo'])" />

<xsl:template match="/links">
<html xmlns="http://www.w3.org/1999/xhtml">
    <link rel="stylesheet" type="text/css" href="style.css"/>
      <body>
      <div id="content">

        <div id="logoo"> <img width="100" height="100" src="{//svgLog/node()}"/> </div>

      <div id ="title"> <xsl:apply-templates select="document($dict1)/dictionary/language"/> ordlista</div>

        <div id="author">
          Författare:  <xsl:apply-templates select="document($dict1)//author"/> </div>


      <p class="words"><xsl:apply-templates select="document($dict1)//word">
                       <xsl:apply-templates select="document($dict2)//word">
              <xsl:sort order="ascending"/>
        </xsl:apply-templates></p>
        </div>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="word">
    <xsl:value-of select="."/>
    <br/>
 </xsl:template>
</xsl:stylesheet>

在CSS,XSL,字典或链接xml中,我在哪里进行更改?

0 个答案:

没有答案