开发者

Is there any application to generate XSL for XML? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools开发者_开发问答, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

Is there any application to generate an XSL Stylesheet from an XML file? I have a very complex XML file, which is a well-formed SVG file.

Is there any software application to convert XML to XSL?


XSL files contain instructions of how to transform a source XML file to another format (may be XML, too). So there is no possibility for a software to transform an XML file to an XSL Stylesheet without having further information on how to do that.

It's like wanting to have a PHP script out of an HTML file. To clarify: A php script could produce the HTML page

<html><body>hello world</body></html>

You cannot deduce what the original script looked like. It may be a simple echo()-call or the result of a complex decoding operation, etc.

The same is for the transformation from XML to XSL. You have to do it by yourself, as a software cannot know how to transform an XML-result to its underlying XSL-transformation sheet.


Based on your previous question, I assume you want to create an XSL-FO file from an SVG image.

One option would be to just include the SVG image inline in a fo:instream-foreign-object. A complete example (using this SVG image):

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <fo:layout-master-set>
    <fo:simple-page-master master-name="master">
      <fo:region-body />
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence master-reference="master">
    <fo:flow flow-name="xsl-region-body">
      <fo:block>
        <fo:instream-foreign-object>

          <svg xmlns="http://www.w3.org/2000/svg"
               width="200" height="200">
            <circle cx="100" cy="100" r="50" stroke="black"
                    stroke-width="5" fill="red" />
          </svg>

        </fo:instream-foreign-object>
      </fo:block> 
    </fo:flow>
  </fo:page-sequence>

</fo:root>

Another option would be to refer to the SVG image from a fo:external-graphic:

<fo:external-graphic src="Svg_example4.svg"/>

If you want automate this, you could just write a XSLT which transforms the SVG to a XSL-FO document with the SVG embedded:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">
  <xsl:template match="/">

    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

      <fo:layout-master-set>
        <fo:simple-page-master master-name="master">
          <fo:region-body />
        </fo:simple-page-master>
      </fo:layout-master-set>

      <fo:page-sequence master-reference="master">
        <fo:flow flow-name="xsl-region-body">
          <fo:block>
            <fo:instream-foreign-object>
              <xsl:copy-of select="." />
            </fo:instream-foreign-object>
          </fo:block> 
        </fo:flow>
      </fo:page-sequence>

    </fo:root>    

  </xsl:template>
</xsl:stylesheet>


No, but you could use some solutions that help you create the XSL files easier. E.g. Altova XMLSpy


XSL can be used to produce XSL from XML. But as XSL already is XML, this simple fact doesn't get you much specifically.

Can you specify some source XML and the desired XSL? Without knowing what you're trying to accomplish, not much more can be said.

There are some interesting examples of such in Chapter 10 (Code Generation) of

Is there any application to generate XSL for XML? [closed]


IntelliJ can generate an XSD from an XML file and visa versa. I'm not sure if the community edition has the capability, but the licensed version can.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜