namespace in root
Here should go questions about transforming XML with XSLT and FOP.
namespace in root
I am really new to xslt. I am trying to transform a xml file using xslt 2.0 in oxygen using the Saxon-EE 9.4.0.6 transformer.
Here's the xml:
<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet href='../codebook2-0.xsl' type='text/xsl'?>
<codeBook xmlns="http://www.icpsr.umich.edu/DDI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.icpsr.umich.edu/DDI http://www.icpsr.umich.edu/DDI/Version1-3.xsd">
<docDscr source="archive">
<citation>
<titlStmt source="archive">
<titl source="archive">Work Trends Poll: Laid Off--American Workers and Employers Assess a Volatile Labor Market</titl>
</titlStmt>
<holdings URI="http://www.ropercenter.uconn.edu/cgi-bi ... RKTRENDS14"/>
</citation>
</docDscr>
</codeBook>
When I apply this sample stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Title of study</h2>
<h1><xsl:value-of select="codeBook/docDscr/citation/titlStmt/titl"/></h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The only result is my text that I put in h2 or Title of Study.
If I remove the xmlns="http://www.icpsr.umich.edu/DDI" from the root <codeBook>, then this stylesheet works fine.
I'm just wondering if someone can explain why removing this xmlns declaration from the root <codeBook> would have that effect.
Thanks for the help.
Here's the xml:
<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet href='../codebook2-0.xsl' type='text/xsl'?>
<codeBook xmlns="http://www.icpsr.umich.edu/DDI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.icpsr.umich.edu/DDI http://www.icpsr.umich.edu/DDI/Version1-3.xsd">
<docDscr source="archive">
<citation>
<titlStmt source="archive">
<titl source="archive">Work Trends Poll: Laid Off--American Workers and Employers Assess a Volatile Labor Market</titl>
</titlStmt>
<holdings URI="http://www.ropercenter.uconn.edu/cgi-bi ... RKTRENDS14"/>
</citation>
</docDscr>
</codeBook>
When I apply this sample stylesheet:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Title of study</h2>
<h1><xsl:value-of select="codeBook/docDscr/citation/titlStmt/titl"/></h1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The only result is my text that I put in h2 or Title of Study.
If I remove the xmlns="http://www.icpsr.umich.edu/DDI" from the root <codeBook>, then this stylesheet works fine.
I'm just wondering if someone can explain why removing this xmlns declaration from the root <codeBook> would have that effect.
Thanks for the help.
Re: namespace in root
The name tests in the XPath expression select those elements from no namespace. As your elements are in the http://www.icpsr.umich.edu/DDI namespace they are not selected. When you remove the namespace declaration on the XML element then the XPath expression selects them. To select the elements in that namespace there are two possibilities:
1. Add
on the xsl:stylesheet element
2. Add a namespace declaration for your namespace like
and then use that prefix for each name test in the XPath expression:
Best Regards,
George
1. Add
Code: Select all
xpath-default-namespace="http://www.icpsr.umich.edu/DDI"
2. Add a namespace declaration for your namespace like
Code: Select all
xmlns:ddi="http://www.icpsr.umich.edu/DDI"
Code: Select all
<xsl:value-of select="ddi:codeBook/ddi:docDscr/ddi:citation/ddi:titlStmt/ddi:titl"/>
George
George Cristian Bina
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service